POWERED BY FREIGHTCOMCanadian shipping expertise. Built into your business.
{"languages":[{"language_key":"curl","language_name":"cURL / Bash","syntax":"bash"},{"language_key":"javascript","language_name":"JavaScript / Node.js","syntax":"javascript"},{"language_key":"typescript","language_name":"TypeScript / Node.js","syntax":"typescript"},{"language_key":"python","language_name":"Python","syntax":"python"},{"language_key":"php","language_name":"PHP","syntax":"php"},{"language_key":"csharp","language_name":"C# / .NET","syntax":"csharp"},{"language_key":"java","language_name":"Java","syntax":"java"},{"language_key":"go","language_name":"Go","syntax":"go"},{"language_key":"ruby","language_name":"Ruby","syntax":"ruby"},{"language_key":"powershell","language_name":"PowerShell","syntax":"powershell"},{"language_key":"kotlin","language_name":"Kotlin / JVM","syntax":"kotlin"},{"language_key":"swift","language_name":"Swift / server","syntax":"swift"},{"language_key":"rust","language_name":"Rust","syntax":"rust"}],"sections":[{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/services\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/services', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/services');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/services\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/services\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/services')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/services'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/services\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/services\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<section class=\"access-process\" aria-labelledby=\"access-process-heading\"><div class=\"access-process-heading\"><div><span class=\"access-process-eyebrow\">FROM APPLICATION TO LIVE SHIPPING</span><h2 id=\"access-process-heading\">Get connected in four steps.</h2></div><span class=\"access-cost-badge\">No API usage fee</span></div><ol class=\"access-process-steps\"><li><span aria-hidden=\"true\" class=\"access-step-number\">01</span><h3>Apply for API access</h3><p>Already have a Freightcom or ClickShip account? Complete the API application form. If you don’t have an account, sign up today.</p><div class=\"access-step-links\"><a href=\"/apply-for-api/\">API application form ↗</a><a href=\"https://live.freightcom.com/signup\" rel=\"noopener noreferrer\" target=\"_blank\">Sign up today ↗</a></div></li><li><span aria-hidden=\"true\" class=\"access-step-number\">02</span><h3>Sign your API agreement</h3><p>We’ll send you an API usage agreement. There is no cost to use the API. You only pay for the shipments you place.</p></li><li><span aria-hidden=\"true\" class=\"access-step-number\">03</span><h3>Integrate and test</h3><p>We’ll issue test tokens for your integration. Use them to build your connection and complete testing.</p></li><li><span aria-hidden=\"true\" class=\"access-step-number\">04</span><h3>Generate your live tokens</h3><p>Once testing is complete, generate live API tokens in your Freightcom account and start shipping through your integration.</p></li></ol><div class=\"access-activity-note\" role=\"note\"><strong>Keep your API connection active.</strong><span>Shipping activity is required to maintain an active API connection.</span></div></section><h2>Build your first API request.</h2><p>After receiving your test tokens, start with a read-only request. Keep the same language selected as you move through rating, booking and tracking.</p><div class=\"docs-step\"><span>01</span><div><h3>Authenticate on your server</h3><p>Set FREIGHTCOM_TOKEN. Send the raw token in the Authorization header.</p><a href=\"#authentication\" data-topic=\"access\">Authentication & setup →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve your available services</h3><p>Run GET /services using the code beside this guide. Use returned service IDs in later requests.</p><a href=\"#get-services\" data-topic=\"get-services\">Service fields & responses →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Request and compare rates</h3><p>Supply shipment details, then poll until status.done is true.</p><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Full rating workflow →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Book, retrieve labels and track</h3><p>Review the service and payment method before booking. Preserve shipment IDs for tracking and reconciliation.</p><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Full booking workflow →</a></div></div><div class=\"doc-callout\"><strong>Before your first booking</strong>Use your issued test tokens during integration and testing. Follow the testing instructions provided with your tokens and replace sample account and shipment details before running requests. Generate live tokens in your Freightcom account only after testing is complete.</div>","section_slug":"quickstart","section_title":"Quickstart","summary":"Authentication, rates, booking and tracking"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/services\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/services', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/services');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/services\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/services\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/services')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/services'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/services\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/services\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/access/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<p>The API uses your token directly in the <code>Authorization</code> header. Keep it in a server-side environment variable. The supplied specification does not declare a Bearer prefix.</p><div class=\"code-panel\"><div class=\"code-toolbar\"><span>BASE URL</span></div><pre>https://external-api.freightcom.com</pre></div><ol><li>Complete the <a href=\"/apply-for-api/\">API application form</a> using your Freightcom or ClickShip account, then sign the API usage agreement. If you need an account, <a href=\"https://live.freightcom.com/signup\" target=\"_blank\" rel=\"noopener noreferrer\">sign up today</a>.</li><li>Configure <code>FREIGHTCOM_TOKEN</code> in your server environment. Never put it in frontend code, source control or public examples.</li><li>Call <code>GET /services</code> to retrieve your account’s service IDs.</li><li>Call <code>GET /finance/payment-methods</code> before booking.</li></ol><div class=\"notice\">Freightcom will issue test tokens for integration and testing. Follow the testing instructions provided with your tokens. Once testing is complete, generate live tokens in your Freightcom account. Shipping activity is required to keep your API connection active. Live shipment bookings and prepaid reloads have financial effects.</div>","section_slug":"authentication","section_title":"Authentication & first request","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in cURL / Bash. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/rate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#rate-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Node.js 20+: node rate-workflow.mjs","snippets":[{"code_text":"import { readFileSync, writeFileSync } from 'node:fs';\nconst base = 'https://external-api.freightcom.com';\nclass ApiError extends Error {\n constructor(status, text, retryAfter = null) {\n super(`HTTP ${status}: ${text}`);\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\nasync function request(method, path, body, timeoutMs = 30000) {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token?.trim()) throw new Error('Set FREIGHTCOM_TOKEN');\n const response = await fetch(base + path, {\n method, redirect: 'error',\n headers: { Authorization: token, 'Content-Type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(Math.max(1, Math.ceil(timeoutMs)))\n });\n const text = await response.text();\n if (!response.ok) throw new ApiError(response.status, text, response.headers.get('Retry-After'));\n // Pending shipment/manifest responses and cancellation responses may be empty.\n return { status: response.status, data: text.trim() ? JSON.parse(text) : null };\n}\nfunction retryDelay(value, fallbackMs) {\n if (!value) return fallbackMs;\n const seconds = Number(value);\n return Number.isFinite(seconds) ? Math.max(0, seconds * 1000)\n : Math.max(0, Date.parse(value) - Date.now()) || fallbackMs;\n}\nasync function poll(path, complete, timeoutMs = 90000) {\n const deadline = performance.now() + timeoutMs;\n let failures = 0;\n while (performance.now() < deadline) {\n let waitMs = 1500;\n try {\n const result = await request('GET', path, undefined, Math.min(30000, deadline - performance.now()));\n if (complete(result)) return result.data;\n failures = 0;\n } catch (error) {\n if (!(error instanceof ApiError) || ![429, 502, 503, 504].includes(error.status)) throw error;\n failures += 1;\n waitMs = retryDelay(error.retryAfter, Math.min(10000, 1500 * 2 ** Math.min(failures, 3)));\n }\n const remaining = deadline - performance.now();\n if (remaining > 0) await new Promise(resolve => setTimeout(resolve, Math.min(waitMs, remaining)));\n }\n throw new Error(`Polling deadline reached for ${path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.`);\n}\nfunction validatePayload(payload) {\n if (JSON.stringify(payload).includes('REPLACE_')) throw new Error('Replace all placeholders before sending');\n const d = payload.details?.expected_ship_date;\n if (!d || ![d.year, d.month, d.day].every(Number.isInteger)) throw new Error('Provide expected_ship_date as integer year, month and day');\n const date = new Date(Date.UTC(d.year, d.month - 1, d.day));\n if (date.getUTCFullYear() !== d.year || date.getUTCMonth() + 1 !== d.month || date.getUTCDate() !== d.day)\n throw new Error('expected_ship_date is not a valid calendar date');\n const today = new Date().toISOString().slice(0, 10);\n if (date.toISOString().slice(0, 10) < today) throw new Error('Replace the expired sample shipping date and any pickup or dispatch dates');\n}\n\nconst payload = JSON.parse(readFileSync('rate-request.json', 'utf8'));\nvalidatePayload(payload);\nconst accepted = await request('POST', '/rate', payload);\nif (accepted.status !== 202 || typeof accepted.data?.request_id !== 'string' || !accepted.data.request_id)\n throw new Error('Expected HTTP 202 with request_id');\nconst id = accepted.data.request_id;\nconsole.log('Rate request ID:', id);\nconst result = await poll('/rate/' + encodeURIComponent(id), r => r.status === 200 && r.data?.status?.done === true);\nif (!Array.isArray(result.rates) || !result.rates.length) throw new Error('No eligible rates. Review shipment details and enabled account services.');\nfor (const rate of result.rates) {\n console.log({ service_id: rate.service_id, carrier: rate.carrier_name,\n service: rate.service_name, total: rate.total,\n transit_days: rate.transit_time_not_available ? null : rate.transit_time_days,\n valid_until: rate.valid_until });\n}\n// Money.value remains a string of minor currency units. Select a returned service explicitly.\n","file_name":"rate-workflow.mjs","snippet_title":"rate-workflow.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"rate-request.json","snippet_title":"rate-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in TypeScript / Node.js. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#rate-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Python 3.10+: python rate_workflow.py","snippets":[{"code_text":"import datetime\nimport email.utils\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nBASE = 'https://external-api.freightcom.com'\n\nclass ApiError(RuntimeError):\n def __init__(self, status, text, retry_after=None):\n super().__init__(f'HTTP {status}: {text}')\n self.status = status\n self.retry_after = retry_after\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n return None\n\ndef request(method, path, body=None, timeout_seconds=30):\n token = os.environ.get('FREIGHTCOM_TOKEN', '')\n if not token.strip():\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\n req = urllib.request.Request(BASE + path, method=method,\n data=None if body is None else json.dumps(body, ensure_ascii=False).encode('utf-8'),\n headers={'Authorization': token, 'Content-Type': 'application/json'})\n try:\n with urllib.request.build_opener(NoRedirect).open(req, timeout=max(.001, timeout_seconds)) as response:\n text = response.read().decode('utf-8')\n return response.status, json.loads(text) if text.strip() else None\n except urllib.error.HTTPError as error:\n raise ApiError(error.code, error.read().decode('utf-8', errors='replace'), error.headers.get('Retry-After')) from error\n\ndef retry_delay(value, fallback):\n if not value:\n return fallback\n try:\n return max(0, float(value))\n except ValueError:\n try:\n return max(0, email.utils.parsedate_to_datetime(value).timestamp() - time.time())\n except (ValueError, TypeError, OverflowError):\n return fallback\n\ndef poll(path, complete, timeout_seconds=90):\n deadline = time.monotonic() + timeout_seconds\n failures = 0\n while time.monotonic() < deadline:\n wait = 1.5\n try:\n status, data = request('GET', path, timeout_seconds=min(30, deadline - time.monotonic()))\n if complete(status, data):\n return data\n failures = 0\n except ApiError as error:\n if error.status not in (429, 502, 503, 504):\n raise\n failures += 1\n wait = retry_delay(error.retry_after, min(10, 1.5 * 2 ** min(failures, 3)))\n remaining = deadline - time.monotonic()\n if remaining > 0:\n time.sleep(min(wait, remaining))\n raise TimeoutError(f'Polling deadline reached for {path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.')\n\ndef validate_payload(payload):\n if 'REPLACE_' in json.dumps(payload):\n raise ValueError('Replace all placeholders before sending')\n d = payload.get('details', {}).get('expected_ship_date', {})\n if not all(type(d.get(k)) is int for k in ('year', 'month', 'day')):\n raise ValueError('Provide expected_ship_date as integer year, month and day')\n ship_date = datetime.date(d['year'], d['month'], d['day'])\n if ship_date < datetime.datetime.now(datetime.timezone.utc).date():\n raise ValueError('Replace the expired sample shipping date and any pickup or dispatch dates')\n\nfrom urllib.parse import quote\n\nwith open('rate-request.json', encoding='utf-8') as source:\n payload = json.load(source)\nvalidate_payload(payload)\nstatus, accepted = request('POST', '/rate', payload)\nif status != 202 or not isinstance(accepted, dict) or not isinstance(accepted.get('request_id'), str) or not accepted['request_id']:\n raise RuntimeError('Expected HTTP 202 with request_id')\nprint('Rate request ID:', accepted['request_id'])\nresult = poll('/rate/' + quote(accepted['request_id'], safe=''),\n lambda status, data: status == 200 and isinstance(data, dict) and isinstance(data.get('status'), dict) and data['status'].get('done') is True)\nif not isinstance(result.get('rates'), list) or not result['rates']:\n raise RuntimeError('No eligible rates. Review shipment details and enabled account services.')\nfor rate in result['rates']:\n print(json.dumps({'service_id': rate.get('service_id'), 'carrier': rate.get('carrier_name'),\n 'service': rate.get('service_name'), 'total': rate.get('total'),\n 'transit_days': None if rate.get('transit_time_not_available') else rate.get('transit_time_days'),\n 'valid_until': rate.get('valid_until')}))\n# Money.value remains a string of minor currency units. Select a returned service explicitly.\n","file_name":"rate_workflow.py","snippet_title":"rate_workflow.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"rate-request.json","snippet_title":"rate-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in PHP. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/rate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in C# / .NET. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/rate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Java. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Go. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/rate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Ruby. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/rate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in PowerShell. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/rate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Kotlin / JVM. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Swift / server. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/rate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Rust. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/rate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/first-shipment/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<ol><li><strong>Prepare the details.</strong> Provide complete origin and destination records, a future shipping date, packaging type and accurate measurements. The domestic parcel template includes the documented required fields.</li><li><strong>Request rates.</strong> Send <code>POST /rate</code>. A <code>202</code> response returns <code>request_id</code>.</li><li><strong>Wait for rating completion.</strong> Poll <code>GET /rate/{rate_id}</code>. A <code>200</code> response alone does not mean all rate lookups finished. Read <code>status.done</code>.</li><li><strong>Choose a service.</strong> Check cost, service suitability, transit availability and rate expiry. Use the returned <code>service_id</code>.</li><li><strong>Book deliberately.</strong> Submit <code>POST /shipment</code> with a stable <code>unique_id</code>, payment method, service ID, shipping details and applicable pickup or dispatch details.</li><li><strong>Retrieve the result.</strong> Booking returns <code>202</code> and <code>id</code>. Poll <code>GET /shipment/{shipment_id}</code> while it returns <code>202</code>. Inspect the final shipment, tracking numbers and label URLs.</li></ol>","section_slug":"first-shipment","section_title":"Your first shipment","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in cURL / Bash. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Node.js 20+: node booking-workflow.mjs","snippets":[{"code_text":"import { readFileSync, writeFileSync } from 'node:fs';\nconst base = 'https://external-api.freightcom.com';\nclass ApiError extends Error {\n constructor(status, text, retryAfter = null) {\n super(`HTTP ${status}: ${text}`);\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\nasync function request(method, path, body, timeoutMs = 30000) {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token?.trim()) throw new Error('Set FREIGHTCOM_TOKEN');\n const response = await fetch(base + path, {\n method, redirect: 'error',\n headers: { Authorization: token, 'Content-Type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(Math.max(1, Math.ceil(timeoutMs)))\n });\n const text = await response.text();\n if (!response.ok) throw new ApiError(response.status, text, response.headers.get('Retry-After'));\n // Pending shipment/manifest responses and cancellation responses may be empty.\n return { status: response.status, data: text.trim() ? JSON.parse(text) : null };\n}\nfunction retryDelay(value, fallbackMs) {\n if (!value) return fallbackMs;\n const seconds = Number(value);\n return Number.isFinite(seconds) ? Math.max(0, seconds * 1000)\n : Math.max(0, Date.parse(value) - Date.now()) || fallbackMs;\n}\nasync function poll(path, complete, timeoutMs = 90000) {\n const deadline = performance.now() + timeoutMs;\n let failures = 0;\n while (performance.now() < deadline) {\n let waitMs = 1500;\n try {\n const result = await request('GET', path, undefined, Math.min(30000, deadline - performance.now()));\n if (complete(result)) return result.data;\n failures = 0;\n } catch (error) {\n if (!(error instanceof ApiError) || ![429, 502, 503, 504].includes(error.status)) throw error;\n failures += 1;\n waitMs = retryDelay(error.retryAfter, Math.min(10000, 1500 * 2 ** Math.min(failures, 3)));\n }\n const remaining = deadline - performance.now();\n if (remaining > 0) await new Promise(resolve => setTimeout(resolve, Math.min(waitMs, remaining)));\n }\n throw new Error(`Polling deadline reached for ${path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.`);\n}\nfunction validatePayload(payload) {\n if (JSON.stringify(payload).includes('REPLACE_')) throw new Error('Replace all placeholders before sending');\n const d = payload.details?.expected_ship_date;\n if (!d || ![d.year, d.month, d.day].every(Number.isInteger)) throw new Error('Provide expected_ship_date as integer year, month and day');\n const date = new Date(Date.UTC(d.year, d.month - 1, d.day));\n if (date.getUTCFullYear() !== d.year || date.getUTCMonth() + 1 !== d.month || date.getUTCDate() !== d.day)\n throw new Error('expected_ship_date is not a valid calendar date');\n const today = new Date().toISOString().slice(0, 10);\n if (date.toISOString().slice(0, 10) < today) throw new Error('Replace the expired sample shipping date and any pickup or dispatch dates');\n}\n\n// Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume an accepted booking without another POST.\nlet shipmentId = process.env.FREIGHTCOM_RESUME_SHIPMENT_ID;\nif (!shipmentId) {\n if (process.env.FREIGHTCOM_CONFIRM_BOOKING !== 'YES')\n throw new Error('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after reviewing booking-request.json.');\n const payload = JSON.parse(readFileSync('booking-request.json', 'utf8'));\n validatePayload(payload);\n if (typeof payload.unique_id !== 'string' || !payload.unique_id.trim() || payload.unique_id.length > 128)\n throw new Error('Provide a stable unique_id, maximum 128 characters');\n // IDs are case-insensitive. Never generate a different ID to retry the same intent.\n const accepted = await request('POST', '/shipment', payload);\n if (accepted.status !== 202 || typeof accepted.data?.id !== 'string' || !accepted.data.id)\n throw new Error('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.');\n shipmentId = accepted.data.id;\n console.log('Accepted shipment ID:', shipmentId, 'Previously created:', accepted.data.previously_created === true);\n writeFileSync('booking-state.json', JSON.stringify({ unique_id: payload.unique_id, ...accepted.data }, null, 2), { mode: 0o600 });\n}\nconst id = encodeURIComponent(shipmentId);\nconst result = await poll('/shipment/' + id, r => r.status === 200 && !!r.data?.shipment);\nwriteFileSync('shipment-result.json', JSON.stringify(result, null, 2), { mode: 0o600 });\nconsole.log('Shipment state:', result.shipment.state);\nif (['draft', 'cancelled'].includes(result.shipment.state))\n throw new Error('Shipment is not ready to dispatch. Review the saved result before any further booking.');\nfor (const label of result.shipment.labels || []) console.log('Label:', label.format, label.size, label.url);\nif (!result.shipment.labels?.length) console.warn('No labels returned. Inspect the shipment documents and service before dispatch.');\n// These reads are independent of booking. Their failure must never trigger another booking.\nfor (const [name, path] of [['Tracking', '/shipment/' + id + '/tracking-events'], ['Invoices', '/finance/invoices-for-shipment-id/' + id]]) {\n try { console.log(name + ':', (await request('GET', path)).data); }\n catch (error) { console.warn(`${name} retrieval failed for shipment ${shipmentId}. Retrieve it later without rebooking. ${error.message}`); }\n}\n","file_name":"booking-workflow.mjs","snippet_title":"booking-workflow.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in TypeScript / Node.js. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Python 3.10+: python booking_workflow.py","snippets":[{"code_text":"import datetime\nimport email.utils\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nBASE = 'https://external-api.freightcom.com'\n\nclass ApiError(RuntimeError):\n def __init__(self, status, text, retry_after=None):\n super().__init__(f'HTTP {status}: {text}')\n self.status = status\n self.retry_after = retry_after\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n return None\n\ndef request(method, path, body=None, timeout_seconds=30):\n token = os.environ.get('FREIGHTCOM_TOKEN', '')\n if not token.strip():\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\n req = urllib.request.Request(BASE + path, method=method,\n data=None if body is None else json.dumps(body, ensure_ascii=False).encode('utf-8'),\n headers={'Authorization': token, 'Content-Type': 'application/json'})\n try:\n with urllib.request.build_opener(NoRedirect).open(req, timeout=max(.001, timeout_seconds)) as response:\n text = response.read().decode('utf-8')\n return response.status, json.loads(text) if text.strip() else None\n except urllib.error.HTTPError as error:\n raise ApiError(error.code, error.read().decode('utf-8', errors='replace'), error.headers.get('Retry-After')) from error\n\ndef retry_delay(value, fallback):\n if not value:\n return fallback\n try:\n return max(0, float(value))\n except ValueError:\n try:\n return max(0, email.utils.parsedate_to_datetime(value).timestamp() - time.time())\n except (ValueError, TypeError, OverflowError):\n return fallback\n\ndef poll(path, complete, timeout_seconds=90):\n deadline = time.monotonic() + timeout_seconds\n failures = 0\n while time.monotonic() < deadline:\n wait = 1.5\n try:\n status, data = request('GET', path, timeout_seconds=min(30, deadline - time.monotonic()))\n if complete(status, data):\n return data\n failures = 0\n except ApiError as error:\n if error.status not in (429, 502, 503, 504):\n raise\n failures += 1\n wait = retry_delay(error.retry_after, min(10, 1.5 * 2 ** min(failures, 3)))\n remaining = deadline - time.monotonic()\n if remaining > 0:\n time.sleep(min(wait, remaining))\n raise TimeoutError(f'Polling deadline reached for {path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.')\n\ndef validate_payload(payload):\n if 'REPLACE_' in json.dumps(payload):\n raise ValueError('Replace all placeholders before sending')\n d = payload.get('details', {}).get('expected_ship_date', {})\n if not all(type(d.get(k)) is int for k in ('year', 'month', 'day')):\n raise ValueError('Provide expected_ship_date as integer year, month and day')\n ship_date = datetime.date(d['year'], d['month'], d['day'])\n if ship_date < datetime.datetime.now(datetime.timezone.utc).date():\n raise ValueError('Replace the expired sample shipping date and any pickup or dispatch dates')\n\nfrom urllib.parse import quote\n\ndef save_private(filename, value):\n fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)\n with os.fdopen(fd, 'w', encoding='utf-8') as target:\n json.dump(value, target, indent=2)\n\n# Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume retrieval without another POST.\nshipment_id = os.environ.get('FREIGHTCOM_RESUME_SHIPMENT_ID')\nif not shipment_id:\n if os.environ.get('FREIGHTCOM_CONFIRM_BOOKING') != 'YES':\n raise RuntimeError('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after review.')\n with open('booking-request.json', encoding='utf-8') as source:\n payload = json.load(source)\n validate_payload(payload)\n unique_id = payload.get('unique_id')\n if not isinstance(unique_id, str) or not unique_id.strip() or len(unique_id) > 128:\n raise ValueError('Provide a stable unique_id, maximum 128 characters')\n # IDs are case-insensitive. Reuse the same ID for the same shipment intent.\n status, accepted = request('POST', '/shipment', payload)\n if status != 202 or not isinstance(accepted, dict) or not isinstance(accepted.get('id'), str) or not accepted['id']:\n raise RuntimeError('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.')\n shipment_id = accepted['id']\n print('Accepted shipment ID:', shipment_id, 'Previously created:', accepted.get('previously_created') is True)\n save_private('booking-state.json', {'unique_id': unique_id, **accepted})\nencoded_id = quote(shipment_id, safe='')\nresult = poll('/shipment/' + encoded_id,\n lambda status, data: status == 200 and isinstance(data, dict) and bool(data.get('shipment')))\nsave_private('shipment-result.json', result)\nprint('Shipment state:', result['shipment'].get('state'))\nif result['shipment'].get('state') in ('draft', 'cancelled'):\n raise RuntimeError('Shipment is not ready to dispatch. Review the saved result before any further booking.')\nfor label in result['shipment'].get('labels', []):\n print('Label:', label.get('format'), label.get('size'), label.get('url'))\nif not result['shipment'].get('labels'):\n print('No labels returned. Inspect the shipment documents and service before dispatch.')\nfor name, path in [('Tracking', '/shipment/' + encoded_id + '/tracking-events'),\n ('Invoices', '/finance/invoices-for-shipment-id/' + encoded_id)]:\n try:\n print(name + ':', request('GET', path)[1])\n except (RuntimeError, OSError, ValueError) as error:\n print(f'{name} retrieval failed for shipment {shipment_id}. Retrieve it later without rebooking. {error}')\n","file_name":"booking_workflow.py","snippet_title":"booking_workflow.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PHP. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in C# / .NET. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Java. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Go. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Ruby. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PowerShell. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Kotlin / JVM. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Swift / server. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Rust. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/polling/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<div class=\"table-wrap\"><table><thead><tr><th>Situation</th><th>Integration behaviour</th></tr></thead><tbody><tr><td>Rating returns 200</td><td>Inspect status.done. Preserve partial results and any pending state.</td></tr><tr><td>Shipment or manifest returns 202</td><td>Poll the resource with a bounded interval and overall deadline. Store the resource ID.</td></tr><tr><td>Booking request times out</td><td>Reconcile using the same stable unique_id. Do not generate a new ID for an unchanged shipment intent.</td></tr><tr><td>Previously created shipment</td><td>Read previously_created. Matching IDs prevent duplicate in-progress or successful bookings. An errored or cancelled booking permits a new booking under the same ID.</td></tr><tr><td>Authentication or validation failure</td><td>Correct credentials or fields. Do not retry unchanged invalid requests.</td></tr><tr><td>Rate limit or temporary failure</td><td>Use bounded backoff for reads and honour Retry-After when provided. Confirm limits with Freightcom. Do not blindly retry financial mutations.</td></tr><tr><td>Tracking updates</td><td>Poll tracking-events on an appropriate schedule. No webhook endpoint is declared in this specification.</td></tr></tbody></table></div><p class=\"small muted\">Example polling intervals are implementation defaults, not a published Freightcom rate-limit allowance.</p><h3>Resume an accepted booking</h3><p>Set <code>FREIGHTCOM_RESUME_SHIPMENT_ID</code> to the saved shipment ID and rerun the booking workflow. This skips POST /shipment and retrieves the existing booking. Do not repeat a booking because a subsequent tracking or invoice read failed.</p><p>GET polling uses a deadline and caps each request timeout by its remaining budget. Read responses 429, 502, 503 and 504 use bounded backoff and Retry-After when supplied. Mutations are never automatically retried. For pickup scheduling, inspect the returned status until done, timed-out or error, rather than treating HTTP 200 as confirmation.</p>","section_slug":"polling","section_title":"Polling, retries & recovery","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment/hts-validate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/hts-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/hts-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/hts-validate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment/hts-validate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/hts-validate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/hts-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/hts-validate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment/hts-validate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/hts-validate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/hts-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/hts-validate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/hts-validate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/customs/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<h3>CA-to-US packages and courier paks</h3><p>For the documented DDP branch, provide <code>details.customs_data</code>. If <code>customs_invoice.details</code> is present, set its tax recipient to <code>shipper</code> and keep product records consistent. For the documented DDU branch, omit customs_data and set the invoice tax recipient to <code>receiver</code>.</p><h3>HTS validation and guaranteed charges</h3><p>Call <code>POST /shipment/hts-validate</code> with accurate product input. Preserve the recommended code and corresponding description. When setting <code>hsverified</code> to true, include the required original input fields and product name. Set <code>request_guaranteed_customs_charges</code> and inspect the returned <code>is_rate_guaranteed</code>. A request flag alone does not establish a guarantee.</p><h3>CPSC, FDA and EU information</h3><p>Use regulations-validate, intended-use-details and citation-code-details where applicable. Select the appropriate CPSC registered, non-registered or certificate-not-required branch. <code>cpsc_regulated</code> is Boolean. <code>fda_regulated</code> uses the strings <code>yes</code> and <code>no</code>. EU workflows include shipment classification and product identifiers.</p><p>The supplied schema contains some description-versus-schema inconsistencies. Treat the complete reference as the source to inspect and confirm ambiguous requirements with technical support. Do not interpret a missing machine-readable required marker as proof a conditional field is optional.</p><h3>Details to carry through your integration</h3><p>International origins and destinations each require an email address. International bookings require customs_invoice information. Keep the customs product records consistent across rating and booking. Supply product identifiers for US and EU destinations as stated in the field descriptions. Follow the appropriate CPSC information branch and confirm the source’s null-versus-omission inconsistency.</p><p>For paperless customs documents, follow the carrier-specific document types and file-count limits. The total request limit is 6 MB, allowing approximately 4.5 MB of files before Base64 encoding. Include a cusma-form when certifying CUSMA origin and the required composition document when declaring a non-zero steel, aluminum or copper allocation, where the carrier accepts these uploads. Document download URLs returned in paperless_customs_documents expire after one hour.</p>","section_slug":"customs","section_title":"Cross-border & customs","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/payment-methods\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/payment-methods', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/payment-methods', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/payment-methods', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/payment-methods');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/payment-methods\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-methods\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/payment-methods\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/payment-methods')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/payment-methods'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-methods\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/payment-methods\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/payment-methods\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/payments/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<p><code>Money.value</code> is a string of minor currency units. CAD $42.50 is <code>\"4250\"</code>. Use decimal-safe arithmetic or integer minor units, and keep currencies separate.</p><p>After Prepaid Shipping is activated, booking must use the prepaid payment method. Credit cards remain available for prepaid reloads. For DDP with Net Terms, the documentation specifies a separate customs-and-duties payment method. Apply the prepaid override where relevant.</p><p>Retrieve invoices by shipment ID or transaction number, and reconcile line items against your stored quote. Do not assume the quoted amount is the final invoiced amount.</p><h3>Balance and response shapes</h3><p>The Net Terms available balance has no currency and is shared across CAD and USD. Prepaid balances remain separate by currency. The financial-document list description and schema disagree about the outer response shape. Confirm it with your approved test account before writing a parser.</p>","section_slug":"payments","section_title":"Payments & money","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in cURL / Bash. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Node.js 20+: node booking-workflow.mjs","snippets":[{"code_text":"import { readFileSync, writeFileSync } from 'node:fs';\nconst base = 'https://external-api.freightcom.com';\nclass ApiError extends Error {\n constructor(status, text, retryAfter = null) {\n super(`HTTP ${status}: ${text}`);\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\nasync function request(method, path, body, timeoutMs = 30000) {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token?.trim()) throw new Error('Set FREIGHTCOM_TOKEN');\n const response = await fetch(base + path, {\n method, redirect: 'error',\n headers: { Authorization: token, 'Content-Type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(Math.max(1, Math.ceil(timeoutMs)))\n });\n const text = await response.text();\n if (!response.ok) throw new ApiError(response.status, text, response.headers.get('Retry-After'));\n // Pending shipment/manifest responses and cancellation responses may be empty.\n return { status: response.status, data: text.trim() ? JSON.parse(text) : null };\n}\nfunction retryDelay(value, fallbackMs) {\n if (!value) return fallbackMs;\n const seconds = Number(value);\n return Number.isFinite(seconds) ? Math.max(0, seconds * 1000)\n : Math.max(0, Date.parse(value) - Date.now()) || fallbackMs;\n}\nasync function poll(path, complete, timeoutMs = 90000) {\n const deadline = performance.now() + timeoutMs;\n let failures = 0;\n while (performance.now() < deadline) {\n let waitMs = 1500;\n try {\n const result = await request('GET', path, undefined, Math.min(30000, deadline - performance.now()));\n if (complete(result)) return result.data;\n failures = 0;\n } catch (error) {\n if (!(error instanceof ApiError) || ![429, 502, 503, 504].includes(error.status)) throw error;\n failures += 1;\n waitMs = retryDelay(error.retryAfter, Math.min(10000, 1500 * 2 ** Math.min(failures, 3)));\n }\n const remaining = deadline - performance.now();\n if (remaining > 0) await new Promise(resolve => setTimeout(resolve, Math.min(waitMs, remaining)));\n }\n throw new Error(`Polling deadline reached for ${path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.`);\n}\nfunction validatePayload(payload) {\n if (JSON.stringify(payload).includes('REPLACE_')) throw new Error('Replace all placeholders before sending');\n const d = payload.details?.expected_ship_date;\n if (!d || ![d.year, d.month, d.day].every(Number.isInteger)) throw new Error('Provide expected_ship_date as integer year, month and day');\n const date = new Date(Date.UTC(d.year, d.month - 1, d.day));\n if (date.getUTCFullYear() !== d.year || date.getUTCMonth() + 1 !== d.month || date.getUTCDate() !== d.day)\n throw new Error('expected_ship_date is not a valid calendar date');\n const today = new Date().toISOString().slice(0, 10);\n if (date.toISOString().slice(0, 10) < today) throw new Error('Replace the expired sample shipping date and any pickup or dispatch dates');\n}\n\n// Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume an accepted booking without another POST.\nlet shipmentId = process.env.FREIGHTCOM_RESUME_SHIPMENT_ID;\nif (!shipmentId) {\n if (process.env.FREIGHTCOM_CONFIRM_BOOKING !== 'YES')\n throw new Error('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after reviewing booking-request.json.');\n const payload = JSON.parse(readFileSync('booking-request.json', 'utf8'));\n validatePayload(payload);\n if (typeof payload.unique_id !== 'string' || !payload.unique_id.trim() || payload.unique_id.length > 128)\n throw new Error('Provide a stable unique_id, maximum 128 characters');\n // IDs are case-insensitive. Never generate a different ID to retry the same intent.\n const accepted = await request('POST', '/shipment', payload);\n if (accepted.status !== 202 || typeof accepted.data?.id !== 'string' || !accepted.data.id)\n throw new Error('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.');\n shipmentId = accepted.data.id;\n console.log('Accepted shipment ID:', shipmentId, 'Previously created:', accepted.data.previously_created === true);\n writeFileSync('booking-state.json', JSON.stringify({ unique_id: payload.unique_id, ...accepted.data }, null, 2), { mode: 0o600 });\n}\nconst id = encodeURIComponent(shipmentId);\nconst result = await poll('/shipment/' + id, r => r.status === 200 && !!r.data?.shipment);\nwriteFileSync('shipment-result.json', JSON.stringify(result, null, 2), { mode: 0o600 });\nconsole.log('Shipment state:', result.shipment.state);\nif (['draft', 'cancelled'].includes(result.shipment.state))\n throw new Error('Shipment is not ready to dispatch. Review the saved result before any further booking.');\nfor (const label of result.shipment.labels || []) console.log('Label:', label.format, label.size, label.url);\nif (!result.shipment.labels?.length) console.warn('No labels returned. Inspect the shipment documents and service before dispatch.');\n// These reads are independent of booking. Their failure must never trigger another booking.\nfor (const [name, path] of [['Tracking', '/shipment/' + id + '/tracking-events'], ['Invoices', '/finance/invoices-for-shipment-id/' + id]]) {\n try { console.log(name + ':', (await request('GET', path)).data); }\n catch (error) { console.warn(`${name} retrieval failed for shipment ${shipmentId}. Retrieve it later without rebooking. ${error.message}`); }\n}\n","file_name":"booking-workflow.mjs","snippet_title":"booking-workflow.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in TypeScript / Node.js. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Open workflow</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Python 3.10+: python booking_workflow.py","snippets":[{"code_text":"import datetime\nimport email.utils\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nBASE = 'https://external-api.freightcom.com'\n\nclass ApiError(RuntimeError):\n def __init__(self, status, text, retry_after=None):\n super().__init__(f'HTTP {status}: {text}')\n self.status = status\n self.retry_after = retry_after\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n return None\n\ndef request(method, path, body=None, timeout_seconds=30):\n token = os.environ.get('FREIGHTCOM_TOKEN', '')\n if not token.strip():\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\n req = urllib.request.Request(BASE + path, method=method,\n data=None if body is None else json.dumps(body, ensure_ascii=False).encode('utf-8'),\n headers={'Authorization': token, 'Content-Type': 'application/json'})\n try:\n with urllib.request.build_opener(NoRedirect).open(req, timeout=max(.001, timeout_seconds)) as response:\n text = response.read().decode('utf-8')\n return response.status, json.loads(text) if text.strip() else None\n except urllib.error.HTTPError as error:\n raise ApiError(error.code, error.read().decode('utf-8', errors='replace'), error.headers.get('Retry-After')) from error\n\ndef retry_delay(value, fallback):\n if not value:\n return fallback\n try:\n return max(0, float(value))\n except ValueError:\n try:\n return max(0, email.utils.parsedate_to_datetime(value).timestamp() - time.time())\n except (ValueError, TypeError, OverflowError):\n return fallback\n\ndef poll(path, complete, timeout_seconds=90):\n deadline = time.monotonic() + timeout_seconds\n failures = 0\n while time.monotonic() < deadline:\n wait = 1.5\n try:\n status, data = request('GET', path, timeout_seconds=min(30, deadline - time.monotonic()))\n if complete(status, data):\n return data\n failures = 0\n except ApiError as error:\n if error.status not in (429, 502, 503, 504):\n raise\n failures += 1\n wait = retry_delay(error.retry_after, min(10, 1.5 * 2 ** min(failures, 3)))\n remaining = deadline - time.monotonic()\n if remaining > 0:\n time.sleep(min(wait, remaining))\n raise TimeoutError(f'Polling deadline reached for {path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.')\n\ndef validate_payload(payload):\n if 'REPLACE_' in json.dumps(payload):\n raise ValueError('Replace all placeholders before sending')\n d = payload.get('details', {}).get('expected_ship_date', {})\n if not all(type(d.get(k)) is int for k in ('year', 'month', 'day')):\n raise ValueError('Provide expected_ship_date as integer year, month and day')\n ship_date = datetime.date(d['year'], d['month'], d['day'])\n if ship_date < datetime.datetime.now(datetime.timezone.utc).date():\n raise ValueError('Replace the expired sample shipping date and any pickup or dispatch dates')\n\nfrom urllib.parse import quote\n\ndef save_private(filename, value):\n fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)\n with os.fdopen(fd, 'w', encoding='utf-8') as target:\n json.dump(value, target, indent=2)\n\n# Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume retrieval without another POST.\nshipment_id = os.environ.get('FREIGHTCOM_RESUME_SHIPMENT_ID')\nif not shipment_id:\n if os.environ.get('FREIGHTCOM_CONFIRM_BOOKING') != 'YES':\n raise RuntimeError('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after review.')\n with open('booking-request.json', encoding='utf-8') as source:\n payload = json.load(source)\n validate_payload(payload)\n unique_id = payload.get('unique_id')\n if not isinstance(unique_id, str) or not unique_id.strip() or len(unique_id) > 128:\n raise ValueError('Provide a stable unique_id, maximum 128 characters')\n # IDs are case-insensitive. Reuse the same ID for the same shipment intent.\n status, accepted = request('POST', '/shipment', payload)\n if status != 202 or not isinstance(accepted, dict) or not isinstance(accepted.get('id'), str) or not accepted['id']:\n raise RuntimeError('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.')\n shipment_id = accepted['id']\n print('Accepted shipment ID:', shipment_id, 'Previously created:', accepted.get('previously_created') is True)\n save_private('booking-state.json', {'unique_id': unique_id, **accepted})\nencoded_id = quote(shipment_id, safe='')\nresult = poll('/shipment/' + encoded_id,\n lambda status, data: status == 200 and isinstance(data, dict) and bool(data.get('shipment')))\nsave_private('shipment-result.json', result)\nprint('Shipment state:', result['shipment'].get('state'))\nif result['shipment'].get('state') in ('draft', 'cancelled'):\n raise RuntimeError('Shipment is not ready to dispatch. Review the saved result before any further booking.')\nfor label in result['shipment'].get('labels', []):\n print('Label:', label.get('format'), label.get('size'), label.get('url'))\nif not result['shipment'].get('labels'):\n print('No labels returned. Inspect the shipment documents and service before dispatch.')\nfor name, path in [('Tracking', '/shipment/' + encoded_id + '/tracking-events'),\n ('Invoices', '/finance/invoices-for-shipment-id/' + encoded_id)]:\n try:\n print(name + ':', request('GET', path)[1])\n except (RuntimeError, OSError, ValueError) as error:\n print(f'{name} retrieval failed for shipment {shipment_id}. Retrieve it later without rebooking. {error}')\n","file_name":"booking_workflow.py","snippet_title":"booking_workflow.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PHP. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in C# / .NET. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Java. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Go. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Ruby. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PowerShell. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Kotlin / JVM. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Swift / server. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Rust. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/production/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<ul><li>Validate dimensions, weights, dates, country codes and destination fields.</li><li>Check enabled services, account payment methods and commodity eligibility.</li><li>Exercise delayed booking, empty rates, validation errors and duplicate requests in an approved test process.</li><li>Store rate and shipment IDs. Redact tokens, personal information and payment details from logs.</li><li>Test the label format with the actual printer and document retrieval process.</li><li>Define tracking polling, exception escalation, cancellation and financial reconciliation.</li><li>Monitor the official documentation for changes and confirm operational limits with Freightcom.</li></ul><div class=\"notice\">The examples are integration templates reviewed against the supplied v2.10.0 specification. They are not official SDKs and have not been tested against a live customer account.</div><a class=\"text-link\" href=\"https://developer.freightcom.com/\" target=\"_blank\" rel=\"noopener noreferrer\">Official Freightcom documentation</a><h2>Source details requiring account confirmation</h2><p>The official v2.10.0 specification contains inconsistencies. The downloadable original remains unchanged.</p><ul><li>Citation-code keys differ between the example and schema.</li><li>The financial document list declares an object response despite its list description.</li><li>Pickup validation prose and schema use different window names, and exact_match appears only in the prose.</li><li>Some enum fields use the nonstandard type enum. Some nullable and conditionally required fields lack corresponding machine-readable markers.</li><li>Packaging schemas overlap under oneOf. Choose the branch matching packaging_type instead of assuming a generic generated validator correctly resolves it.</li><li>Courier-pak weight and description requirements sit on the array in the source. Include both in each courier_paks item.</li><li>Carrier IDs are required for some operations but are not returned by the documented GET /services schema. Confirm their source with Freightcom.</li></ul><p><a href=\"/assets/api-audit-report.txt\" download=\"\">Download the code audit and validation record</a>.</p>","section_slug":"production","section_title":"Production checklist","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/rate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/rate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/rate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/rate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/rate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/rate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/rate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/rate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/rate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/checkout-rates/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<p>Build real-time parcel and pallet rates into a custom ecommerce checkout through your server. Freightcom rating is asynchronous: requesting a rate and retrieving completed results are separate steps. International services are for parcels only.</p><h2>From cart data to carrier rates</h2><ol><li>Validate origin, destination, expected ship date and a packing plan.</li><li>Choose <code>package</code> or <code>pallet</code> packaging. For pallets include measurements, goods description, freight class and applicable service details.</li><li>Send <code>POST /rate</code> and store the returned <code>request_id</code>.</li><li>Poll <code>GET /rate/{rate_id}</code> until <code>status.done</code> is true or your application’s deadline is reached. HTTP 200 alone does not mean the search is complete.</li><li>Display eligible services and available transit estimates. Preserve the selected service and quote context with the order.</li><li>Revalidate changed shipment details and rate validity before booking. Reconcile the invoice after shipment.</li></ol><h2>Make checkout resilient</h2><p>Debounce input changes, set bounded request and polling timeouts, and make a deliberate decision about incomplete results. Show a useful loading state and an approved fallback for timeouts or no rates. Never show an unavailable delivery estimate as a promise.</p><h2>REST, GraphQL and event architecture</h2><p>Freightcom’s documented interface uses HTTP endpoints and JSON. A headless store or GraphQL storefront connects through your own backend adapter. Keep tokens server-side. Use the documented polling workflow for rates and tracking. A native Freightcom GraphQL endpoint or webhook delivery guarantee is not established by the reviewed documentation.</p><h2>Measure the integration</h2><p>Track request success, completed lookups, time to usable rates, no-rate frequency and quote-to-invoice variance. Segment by parcel and pallet, lane and order type. Do not automatically retry a booking after a timeout without checking its existing outcome.</p>","section_slug":"checkout-rates","section_title":"Real-time checkout rates","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/freight-class/calculate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/freight-class/calculate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/freight-class/calculate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/freight-class/calculate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/freight-class/calculate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/freight-class/calculate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/freight-class/calculate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/freight-class/calculate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/freight-class/calculate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/freight-class/calculate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/freight-class/calculate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/freight-class/calculate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Open endpoint</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/freight-class/calculate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/guides/pallet-rating/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Get started","rich_content":"<p>Use Freightcom’s pallet model for freight shipments. This is a distinct packaging workflow within the same API used for parcels. International services are for parcels only.</p><h2>Map the freight fields</h2><ul><li><code>details.packaging_type</code>: <code>pallet</code>.</li><li><code>packaging_properties.pallet_type</code>: <code>ltl</code>.</li><li><code>packaging_properties.pallets[]</code>: measurements, description and freight_class for each pallet, plus applicable optional fields.</li><li><code>has_stackable_pallets</code>: reflect the loaded freight.</li><li><code>pallet_service_details</code>: capture applicable appointment, limited-access and other documented requirements.</li></ul><h2>Calculate and confirm freight class</h2><p><code>POST /freight-class/calculate</code> accepts a box measurement object and returns a class. Confirm that result against the actual commodity and applicable carrier requirements. Do not assume density alone resolves every freight-class decision.</p><h2>Rate, retrieve, book</h2><p>Submit the shipment to <code>POST /rate</code>, store its request ID and poll the rate retrieval endpoint. Review eligible services before booking. Retrieve available bills of lading and shipping documents after booking completes. Use the official reference for complete origin, destination, dispatch and customs fields.</p><h2>Test realistic freight cases</h2><p>Include a standard commercial delivery, an appointment delivery, limited access, multiple pallets, changed measurements and an unavailable lane in the team’s test plan. Confirm account-specific service behaviour using the issued test tokens.</p>","section_slug":"pallet-rating","section_title":"Pallet rating","summary":"Start & integrate"},{"code_languages":[{"instructions_html":"<h2>Build this sequence in cURL / Bash</h2><p>The first request appears beside this guide. Open each step for its cURL / Bash client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open cURL / Bash example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open cURL / Bash example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The cURL / Bash examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in cURL / Bash. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/rate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Submit → poll → review rates</h2><p>This complete rating example includes request timeouts, bounded polling and error handling. Node.js and Python versions are available through the language pills.</p><ol><li>Copy the workflow and rate-request.json files into one directory.</li><li>Replace origin, destination, shipment measurements and date.</li><li>Set FREIGHTCOM_TOKEN and run the workflow using the instructions beside the code.</li><li>Review returned service IDs, costs, transit availability and rate expiry before selecting a service.</li></ol><div class=\"doc-callout\"><strong>Verification status</strong>Request and workflow checks use a controlled mock server. This does not verify account permissions, carrier availability, live labels or shipment charges. Complete approved test-token and account validation before production. See the Production checklist for the audit record.</div><h3>Operations in this workflow</h3><div class=\"topic-links\"><a href=\"#post-rate\" data-topic=\"post-rate\">Request shipping rates</a><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Retrieve rate results</a></div><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div><p class=\"portal-example-reference\"><a href=\"#rate-workflow\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Node.js 20+: node rate-workflow.mjs","snippets":[{"code_text":"import { readFileSync, writeFileSync } from 'node:fs';\nconst base = 'https://external-api.freightcom.com';\nclass ApiError extends Error {\n constructor(status, text, retryAfter = null) {\n super(`HTTP ${status}: ${text}`);\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\nasync function request(method, path, body, timeoutMs = 30000) {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token?.trim()) throw new Error('Set FREIGHTCOM_TOKEN');\n const response = await fetch(base + path, {\n method, redirect: 'error',\n headers: { Authorization: token, 'Content-Type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(Math.max(1, Math.ceil(timeoutMs)))\n });\n const text = await response.text();\n if (!response.ok) throw new ApiError(response.status, text, response.headers.get('Retry-After'));\n // Pending shipment/manifest responses and cancellation responses may be empty.\n return { status: response.status, data: text.trim() ? JSON.parse(text) : null };\n}\nfunction retryDelay(value, fallbackMs) {\n if (!value) return fallbackMs;\n const seconds = Number(value);\n return Number.isFinite(seconds) ? Math.max(0, seconds * 1000)\n : Math.max(0, Date.parse(value) - Date.now()) || fallbackMs;\n}\nasync function poll(path, complete, timeoutMs = 90000) {\n const deadline = performance.now() + timeoutMs;\n let failures = 0;\n while (performance.now() < deadline) {\n let waitMs = 1500;\n try {\n const result = await request('GET', path, undefined, Math.min(30000, deadline - performance.now()));\n if (complete(result)) return result.data;\n failures = 0;\n } catch (error) {\n if (!(error instanceof ApiError) || ![429, 502, 503, 504].includes(error.status)) throw error;\n failures += 1;\n waitMs = retryDelay(error.retryAfter, Math.min(10000, 1500 * 2 ** Math.min(failures, 3)));\n }\n const remaining = deadline - performance.now();\n if (remaining > 0) await new Promise(resolve => setTimeout(resolve, Math.min(waitMs, remaining)));\n }\n throw new Error(`Polling deadline reached for ${path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.`);\n}\nfunction validatePayload(payload) {\n if (JSON.stringify(payload).includes('REPLACE_')) throw new Error('Replace all placeholders before sending');\n const d = payload.details?.expected_ship_date;\n if (!d || ![d.year, d.month, d.day].every(Number.isInteger)) throw new Error('Provide expected_ship_date as integer year, month and day');\n const date = new Date(Date.UTC(d.year, d.month - 1, d.day));\n if (date.getUTCFullYear() !== d.year || date.getUTCMonth() + 1 !== d.month || date.getUTCDate() !== d.day)\n throw new Error('expected_ship_date is not a valid calendar date');\n const today = new Date().toISOString().slice(0, 10);\n if (date.toISOString().slice(0, 10) < today) throw new Error('Replace the expired sample shipping date and any pickup or dispatch dates');\n}\n\nconst payload = JSON.parse(readFileSync('rate-request.json', 'utf8'));\nvalidatePayload(payload);\nconst accepted = await request('POST', '/rate', payload);\nif (accepted.status !== 202 || typeof accepted.data?.request_id !== 'string' || !accepted.data.request_id)\n throw new Error('Expected HTTP 202 with request_id');\nconst id = accepted.data.request_id;\nconsole.log('Rate request ID:', id);\nconst result = await poll('/rate/' + encodeURIComponent(id), r => r.status === 200 && r.data?.status?.done === true);\nif (!Array.isArray(result.rates) || !result.rates.length) throw new Error('No eligible rates. Review shipment details and enabled account services.');\nfor (const rate of result.rates) {\n console.log({ service_id: rate.service_id, carrier: rate.carrier_name,\n service: rate.service_name, total: rate.total,\n transit_days: rate.transit_time_not_available ? null : rate.transit_time_days,\n valid_until: rate.valid_until });\n}\n// Money.value remains a string of minor currency units. Select a returned service explicitly.\n","file_name":"rate-workflow.mjs","snippet_title":"rate-workflow.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"rate-request.json","snippet_title":"rate-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in TypeScript / Node.js</h2><p>The first request appears beside this guide. Open each step for its TypeScript / Node.js client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open TypeScript / Node.js example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open TypeScript / Node.js example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The TypeScript / Node.js examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in TypeScript / Node.js. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Submit → poll → review rates</h2><p>This complete rating example includes request timeouts, bounded polling and error handling. Node.js and Python versions are available through the language pills.</p><ol><li>Copy the workflow and rate-request.json files into one directory.</li><li>Replace origin, destination, shipment measurements and date.</li><li>Set FREIGHTCOM_TOKEN and run the workflow using the instructions beside the code.</li><li>Review returned service IDs, costs, transit availability and rate expiry before selecting a service.</li></ol><div class=\"doc-callout\"><strong>Verification status</strong>Request and workflow checks use a controlled mock server. This does not verify account permissions, carrier availability, live labels or shipment charges. Complete approved test-token and account validation before production. See the Production checklist for the audit record.</div><h3>Operations in this workflow</h3><div class=\"topic-links\"><a href=\"#post-rate\" data-topic=\"post-rate\">Request shipping rates</a><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Retrieve rate results</a></div><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div><p class=\"portal-example-reference\"><a href=\"#rate-workflow\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Python 3.10+: python rate_workflow.py","snippets":[{"code_text":"import datetime\nimport email.utils\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nBASE = 'https://external-api.freightcom.com'\n\nclass ApiError(RuntimeError):\n def __init__(self, status, text, retry_after=None):\n super().__init__(f'HTTP {status}: {text}')\n self.status = status\n self.retry_after = retry_after\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n return None\n\ndef request(method, path, body=None, timeout_seconds=30):\n token = os.environ.get('FREIGHTCOM_TOKEN', '')\n if not token.strip():\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\n req = urllib.request.Request(BASE + path, method=method,\n data=None if body is None else json.dumps(body, ensure_ascii=False).encode('utf-8'),\n headers={'Authorization': token, 'Content-Type': 'application/json'})\n try:\n with urllib.request.build_opener(NoRedirect).open(req, timeout=max(.001, timeout_seconds)) as response:\n text = response.read().decode('utf-8')\n return response.status, json.loads(text) if text.strip() else None\n except urllib.error.HTTPError as error:\n raise ApiError(error.code, error.read().decode('utf-8', errors='replace'), error.headers.get('Retry-After')) from error\n\ndef retry_delay(value, fallback):\n if not value:\n return fallback\n try:\n return max(0, float(value))\n except ValueError:\n try:\n return max(0, email.utils.parsedate_to_datetime(value).timestamp() - time.time())\n except (ValueError, TypeError, OverflowError):\n return fallback\n\ndef poll(path, complete, timeout_seconds=90):\n deadline = time.monotonic() + timeout_seconds\n failures = 0\n while time.monotonic() < deadline:\n wait = 1.5\n try:\n status, data = request('GET', path, timeout_seconds=min(30, deadline - time.monotonic()))\n if complete(status, data):\n return data\n failures = 0\n except ApiError as error:\n if error.status not in (429, 502, 503, 504):\n raise\n failures += 1\n wait = retry_delay(error.retry_after, min(10, 1.5 * 2 ** min(failures, 3)))\n remaining = deadline - time.monotonic()\n if remaining > 0:\n time.sleep(min(wait, remaining))\n raise TimeoutError(f'Polling deadline reached for {path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.')\n\ndef validate_payload(payload):\n if 'REPLACE_' in json.dumps(payload):\n raise ValueError('Replace all placeholders before sending')\n d = payload.get('details', {}).get('expected_ship_date', {})\n if not all(type(d.get(k)) is int for k in ('year', 'month', 'day')):\n raise ValueError('Provide expected_ship_date as integer year, month and day')\n ship_date = datetime.date(d['year'], d['month'], d['day'])\n if ship_date < datetime.datetime.now(datetime.timezone.utc).date():\n raise ValueError('Replace the expired sample shipping date and any pickup or dispatch dates')\n\nfrom urllib.parse import quote\n\nwith open('rate-request.json', encoding='utf-8') as source:\n payload = json.load(source)\nvalidate_payload(payload)\nstatus, accepted = request('POST', '/rate', payload)\nif status != 202 or not isinstance(accepted, dict) or not isinstance(accepted.get('request_id'), str) or not accepted['request_id']:\n raise RuntimeError('Expected HTTP 202 with request_id')\nprint('Rate request ID:', accepted['request_id'])\nresult = poll('/rate/' + quote(accepted['request_id'], safe=''),\n lambda status, data: status == 200 and isinstance(data, dict) and isinstance(data.get('status'), dict) and data['status'].get('done') is True)\nif not isinstance(result.get('rates'), list) or not result['rates']:\n raise RuntimeError('No eligible rates. Review shipment details and enabled account services.')\nfor rate in result['rates']:\n print(json.dumps({'service_id': rate.get('service_id'), 'carrier': rate.get('carrier_name'),\n 'service': rate.get('service_name'), 'total': rate.get('total'),\n 'transit_days': None if rate.get('transit_time_not_available') else rate.get('transit_time_days'),\n 'valid_until': rate.get('valid_until')}))\n# Money.value remains a string of minor currency units. Select a returned service explicitly.\n","file_name":"rate_workflow.py","snippet_title":"rate_workflow.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"rate-request.json","snippet_title":"rate-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in PHP</h2><p>The first request appears beside this guide. Open each step for its PHP client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open PHP example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open PHP example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The PHP examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in PHP. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/rate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in C# / .NET</h2><p>The first request appears beside this guide. Open each step for its C# / .NET client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open C# / .NET example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open C# / .NET example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The C# / .NET examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in C# / .NET. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/rate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Java</h2><p>The first request appears beside this guide. Open each step for its Java client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Java example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Java example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Java examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Java. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Go</h2><p>The first request appears beside this guide. Open each step for its Go client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Go example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Go example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Go examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Go. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/rate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Ruby</h2><p>The first request appears beside this guide. Open each step for its Ruby client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Ruby example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Ruby example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Ruby examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Ruby. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/rate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in PowerShell</h2><p>The first request appears beside this guide. Open each step for its PowerShell client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open PowerShell example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open PowerShell example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The PowerShell examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in PowerShell. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/rate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Kotlin / JVM</h2><p>The first request appears beside this guide. Open each step for its Kotlin / JVM client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Kotlin / JVM example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Kotlin / JVM example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Kotlin / JVM examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Kotlin / JVM. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Swift / server</h2><p>The first request appears beside this guide. Open each step for its Swift / server client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Swift / server example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Swift / server example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Swift / server examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Swift / server. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/rate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Rust</h2><p>The first request appears beside this guide. Open each step for its Rust client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Request shipping rates</h3><a href=\"#post-rate\" data-topic=\"post-rate\">Open Rust example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve rate results</h3><a href=\"#get-rate-rate-id\" data-topic=\"get-rate-rate-id\">Open Rust example →</a></div></div><h3>Completion & handling</h3><p>POST /rate returns request_id. Poll GET /rate/{rate_id} until status.done is true. HTTP 200 alone does not mean all rates are ready.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Rust examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-rate\">Open endpoint</a></p>","introduction":"Showing the first request in Rust. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/rate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/workflows/rate-workflow/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Complete workflows","rich_content":"","section_slug":"rate-workflow","section_title":"Rate → completed results","summary":"Complete workflows"},{"code_languages":[{"instructions_html":"<h2>Build this sequence in cURL / Bash</h2><p>The first request appears beside this guide. Open each step for its cURL / Bash client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open cURL / Bash example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open cURL / Bash example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open cURL / Bash example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open cURL / Bash example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The cURL / Bash examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in cURL / Bash. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Book → retrieve labels → track</h2><p>This complete booking example includes request timeouts, bounded polling and error handling. Node.js and Python versions are available through the language pills.</p><ol><li>Copy the workflow and booking-request.json files into one directory.</li><li>Supply the reviewed service ID, payment method, shipment details and a stable unique_id.</li><li>Set FREIGHTCOM_TOKEN, review the booking, then set FREIGHTCOM_CONFIRM_BOOKING=YES.</li><li>Run the workflow. Preserve booking-state.json and shipment-result.json privately for recovery.</li><li>Inspect retrieved labels, tracking and invoice information.</li></ol><div class=\"doc-callout\"><strong>Verification status</strong>Request and workflow checks use a controlled mock server. This does not verify account permissions, carrier availability, live labels or shipment charges. Complete approved test-token and account validation before production. See the Production checklist for the audit record.</div><h3>Operations in this workflow</h3><div class=\"topic-links\"><a href=\"#post-shipment\" data-topic=\"post-shipment\">Book a shipment</a><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Retrieve shipment & labels</a><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Retrieve tracking events</a><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Find invoices by shipment</a></div><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Book → labels → tracking</a><a href=\"#first-shipment\" data-topic=\"first-shipment\">Your first shipment</a></div><p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Node.js 20+: node booking-workflow.mjs","snippets":[{"code_text":"import { readFileSync, writeFileSync } from 'node:fs';\nconst base = 'https://external-api.freightcom.com';\nclass ApiError extends Error {\n constructor(status, text, retryAfter = null) {\n super(`HTTP ${status}: ${text}`);\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\nasync function request(method, path, body, timeoutMs = 30000) {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token?.trim()) throw new Error('Set FREIGHTCOM_TOKEN');\n const response = await fetch(base + path, {\n method, redirect: 'error',\n headers: { Authorization: token, 'Content-Type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: AbortSignal.timeout(Math.max(1, Math.ceil(timeoutMs)))\n });\n const text = await response.text();\n if (!response.ok) throw new ApiError(response.status, text, response.headers.get('Retry-After'));\n // Pending shipment/manifest responses and cancellation responses may be empty.\n return { status: response.status, data: text.trim() ? JSON.parse(text) : null };\n}\nfunction retryDelay(value, fallbackMs) {\n if (!value) return fallbackMs;\n const seconds = Number(value);\n return Number.isFinite(seconds) ? Math.max(0, seconds * 1000)\n : Math.max(0, Date.parse(value) - Date.now()) || fallbackMs;\n}\nasync function poll(path, complete, timeoutMs = 90000) {\n const deadline = performance.now() + timeoutMs;\n let failures = 0;\n while (performance.now() < deadline) {\n let waitMs = 1500;\n try {\n const result = await request('GET', path, undefined, Math.min(30000, deadline - performance.now()));\n if (complete(result)) return result.data;\n failures = 0;\n } catch (error) {\n if (!(error instanceof ApiError) || ![429, 502, 503, 504].includes(error.status)) throw error;\n failures += 1;\n waitMs = retryDelay(error.retryAfter, Math.min(10000, 1500 * 2 ** Math.min(failures, 3)));\n }\n const remaining = deadline - performance.now();\n if (remaining > 0) await new Promise(resolve => setTimeout(resolve, Math.min(waitMs, remaining)));\n }\n throw new Error(`Polling deadline reached for ${path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.`);\n}\nfunction validatePayload(payload) {\n if (JSON.stringify(payload).includes('REPLACE_')) throw new Error('Replace all placeholders before sending');\n const d = payload.details?.expected_ship_date;\n if (!d || ![d.year, d.month, d.day].every(Number.isInteger)) throw new Error('Provide expected_ship_date as integer year, month and day');\n const date = new Date(Date.UTC(d.year, d.month - 1, d.day));\n if (date.getUTCFullYear() !== d.year || date.getUTCMonth() + 1 !== d.month || date.getUTCDate() !== d.day)\n throw new Error('expected_ship_date is not a valid calendar date');\n const today = new Date().toISOString().slice(0, 10);\n if (date.toISOString().slice(0, 10) < today) throw new Error('Replace the expired sample shipping date and any pickup or dispatch dates');\n}\n\n// Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume an accepted booking without another POST.\nlet shipmentId = process.env.FREIGHTCOM_RESUME_SHIPMENT_ID;\nif (!shipmentId) {\n if (process.env.FREIGHTCOM_CONFIRM_BOOKING !== 'YES')\n throw new Error('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after reviewing booking-request.json.');\n const payload = JSON.parse(readFileSync('booking-request.json', 'utf8'));\n validatePayload(payload);\n if (typeof payload.unique_id !== 'string' || !payload.unique_id.trim() || payload.unique_id.length > 128)\n throw new Error('Provide a stable unique_id, maximum 128 characters');\n // IDs are case-insensitive. Never generate a different ID to retry the same intent.\n const accepted = await request('POST', '/shipment', payload);\n if (accepted.status !== 202 || typeof accepted.data?.id !== 'string' || !accepted.data.id)\n throw new Error('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.');\n shipmentId = accepted.data.id;\n console.log('Accepted shipment ID:', shipmentId, 'Previously created:', accepted.data.previously_created === true);\n writeFileSync('booking-state.json', JSON.stringify({ unique_id: payload.unique_id, ...accepted.data }, null, 2), { mode: 0o600 });\n}\nconst id = encodeURIComponent(shipmentId);\nconst result = await poll('/shipment/' + id, r => r.status === 200 && !!r.data?.shipment);\nwriteFileSync('shipment-result.json', JSON.stringify(result, null, 2), { mode: 0o600 });\nconsole.log('Shipment state:', result.shipment.state);\nif (['draft', 'cancelled'].includes(result.shipment.state))\n throw new Error('Shipment is not ready to dispatch. Review the saved result before any further booking.');\nfor (const label of result.shipment.labels || []) console.log('Label:', label.format, label.size, label.url);\nif (!result.shipment.labels?.length) console.warn('No labels returned. Inspect the shipment documents and service before dispatch.');\n// These reads are independent of booking. Their failure must never trigger another booking.\nfor (const [name, path] of [['Tracking', '/shipment/' + id + '/tracking-events'], ['Invoices', '/finance/invoices-for-shipment-id/' + id]]) {\n try { console.log(name + ':', (await request('GET', path)).data); }\n catch (error) { console.warn(`${name} retrieval failed for shipment ${shipmentId}. Retrieve it later without rebooking. ${error.message}`); }\n}\n","file_name":"booking-workflow.mjs","snippet_title":"booking-workflow.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in TypeScript / Node.js</h2><p>The first request appears beside this guide. Open each step for its TypeScript / Node.js client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open TypeScript / Node.js example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open TypeScript / Node.js example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open TypeScript / Node.js example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open TypeScript / Node.js example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The TypeScript / Node.js examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in TypeScript / Node.js. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Book → retrieve labels → track</h2><p>This complete booking example includes request timeouts, bounded polling and error handling. Node.js and Python versions are available through the language pills.</p><ol><li>Copy the workflow and booking-request.json files into one directory.</li><li>Supply the reviewed service ID, payment method, shipment details and a stable unique_id.</li><li>Set FREIGHTCOM_TOKEN, review the booking, then set FREIGHTCOM_CONFIRM_BOOKING=YES.</li><li>Run the workflow. Preserve booking-state.json and shipment-result.json privately for recovery.</li><li>Inspect retrieved labels, tracking and invoice information.</li></ol><div class=\"doc-callout\"><strong>Verification status</strong>Request and workflow checks use a controlled mock server. This does not verify account permissions, carrier availability, live labels or shipment charges. Complete approved test-token and account validation before production. See the Production checklist for the audit record.</div><h3>Operations in this workflow</h3><div class=\"topic-links\"><a href=\"#post-shipment\" data-topic=\"post-shipment\">Book a shipment</a><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Retrieve shipment & labels</a><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Retrieve tracking events</a><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Find invoices by shipment</a></div><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Book → labels → tracking</a><a href=\"#first-shipment\" data-topic=\"first-shipment\">Your first shipment</a></div><p class=\"portal-example-reference\"><a href=\"#booking-workflow\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Set FREIGHTCOM_CONFIRM_BOOKING=YES only after reviewing the shipment. Preserve generated state files for recovery. Set FREIGHTCOM_RESUME_SHIPMENT_ID to retrieve an accepted shipment without another booking request. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Python 3.10+: python booking_workflow.py","snippets":[{"code_text":"import datetime\nimport email.utils\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nBASE = 'https://external-api.freightcom.com'\n\nclass ApiError(RuntimeError):\n def __init__(self, status, text, retry_after=None):\n super().__init__(f'HTTP {status}: {text}')\n self.status = status\n self.retry_after = retry_after\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n return None\n\ndef request(method, path, body=None, timeout_seconds=30):\n token = os.environ.get('FREIGHTCOM_TOKEN', '')\n if not token.strip():\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\n req = urllib.request.Request(BASE + path, method=method,\n data=None if body is None else json.dumps(body, ensure_ascii=False).encode('utf-8'),\n headers={'Authorization': token, 'Content-Type': 'application/json'})\n try:\n with urllib.request.build_opener(NoRedirect).open(req, timeout=max(.001, timeout_seconds)) as response:\n text = response.read().decode('utf-8')\n return response.status, json.loads(text) if text.strip() else None\n except urllib.error.HTTPError as error:\n raise ApiError(error.code, error.read().decode('utf-8', errors='replace'), error.headers.get('Retry-After')) from error\n\ndef retry_delay(value, fallback):\n if not value:\n return fallback\n try:\n return max(0, float(value))\n except ValueError:\n try:\n return max(0, email.utils.parsedate_to_datetime(value).timestamp() - time.time())\n except (ValueError, TypeError, OverflowError):\n return fallback\n\ndef poll(path, complete, timeout_seconds=90):\n deadline = time.monotonic() + timeout_seconds\n failures = 0\n while time.monotonic() < deadline:\n wait = 1.5\n try:\n status, data = request('GET', path, timeout_seconds=min(30, deadline - time.monotonic()))\n if complete(status, data):\n return data\n failures = 0\n except ApiError as error:\n if error.status not in (429, 502, 503, 504):\n raise\n failures += 1\n wait = retry_delay(error.retry_after, min(10, 1.5 * 2 ** min(failures, 3)))\n remaining = deadline - time.monotonic()\n if remaining > 0:\n time.sleep(min(wait, remaining))\n raise TimeoutError(f'Polling deadline reached for {path}. Preserve the resource ID and resume retrieval. Do not create a new shipment to retry a read.')\n\ndef validate_payload(payload):\n if 'REPLACE_' in json.dumps(payload):\n raise ValueError('Replace all placeholders before sending')\n d = payload.get('details', {}).get('expected_ship_date', {})\n if not all(type(d.get(k)) is int for k in ('year', 'month', 'day')):\n raise ValueError('Provide expected_ship_date as integer year, month and day')\n ship_date = datetime.date(d['year'], d['month'], d['day'])\n if ship_date < datetime.datetime.now(datetime.timezone.utc).date():\n raise ValueError('Replace the expired sample shipping date and any pickup or dispatch dates')\n\nfrom urllib.parse import quote\n\ndef save_private(filename, value):\n fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)\n with os.fdopen(fd, 'w', encoding='utf-8') as target:\n json.dump(value, target, indent=2)\n\n# Set FREIGHTCOM_RESUME_SHIPMENT_ID to resume retrieval without another POST.\nshipment_id = os.environ.get('FREIGHTCOM_RESUME_SHIPMENT_ID')\nif not shipment_id:\n if os.environ.get('FREIGHTCOM_CONFIRM_BOOKING') != 'YES':\n raise RuntimeError('Booking incurs charges with live tokens. Set FREIGHTCOM_CONFIRM_BOOKING=YES after review.')\n with open('booking-request.json', encoding='utf-8') as source:\n payload = json.load(source)\n validate_payload(payload)\n unique_id = payload.get('unique_id')\n if not isinstance(unique_id, str) or not unique_id.strip() or len(unique_id) > 128:\n raise ValueError('Provide a stable unique_id, maximum 128 characters')\n # IDs are case-insensitive. Reuse the same ID for the same shipment intent.\n status, accepted = request('POST', '/shipment', payload)\n if status != 202 or not isinstance(accepted, dict) or not isinstance(accepted.get('id'), str) or not accepted['id']:\n raise RuntimeError('Expected HTTP 202 with shipment id. Reconcile this booking before another POST.')\n shipment_id = accepted['id']\n print('Accepted shipment ID:', shipment_id, 'Previously created:', accepted.get('previously_created') is True)\n save_private('booking-state.json', {'unique_id': unique_id, **accepted})\nencoded_id = quote(shipment_id, safe='')\nresult = poll('/shipment/' + encoded_id,\n lambda status, data: status == 200 and isinstance(data, dict) and bool(data.get('shipment')))\nsave_private('shipment-result.json', result)\nprint('Shipment state:', result['shipment'].get('state'))\nif result['shipment'].get('state') in ('draft', 'cancelled'):\n raise RuntimeError('Shipment is not ready to dispatch. Review the saved result before any further booking.')\nfor label in result['shipment'].get('labels', []):\n print('Label:', label.get('format'), label.get('size'), label.get('url'))\nif not result['shipment'].get('labels'):\n print('No labels returned. Inspect the shipment documents and service before dispatch.')\nfor name, path in [('Tracking', '/shipment/' + encoded_id + '/tracking-events'),\n ('Invoices', '/finance/invoices-for-shipment-id/' + encoded_id)]:\n try:\n print(name + ':', request('GET', path)[1])\n except (RuntimeError, OSError, ValueError) as error:\n print(f'{name} retrieval failed for shipment {shipment_id}. Retrieve it later without rebooking. {error}')\n","file_name":"booking_workflow.py","snippet_title":"booking_workflow.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"booking-request.json","snippet_title":"booking-request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in PHP</h2><p>The first request appears beside this guide. Open each step for its PHP client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open PHP example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open PHP example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open PHP example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open PHP example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The PHP examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PHP. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in C# / .NET</h2><p>The first request appears beside this guide. Open each step for its C# / .NET client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open C# / .NET example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open C# / .NET example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open C# / .NET example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open C# / .NET example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The C# / .NET examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in C# / .NET. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Java</h2><p>The first request appears beside this guide. Open each step for its Java client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Java example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Java example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Java example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Java example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Java examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Java. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Go</h2><p>The first request appears beside this guide. Open each step for its Go client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Go example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Go example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Go example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Go example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Go examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Go. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Ruby</h2><p>The first request appears beside this guide. Open each step for its Ruby client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Ruby example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Ruby example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Ruby example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Ruby example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Ruby examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Ruby. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in PowerShell</h2><p>The first request appears beside this guide. Open each step for its PowerShell client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open PowerShell example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open PowerShell example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open PowerShell example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open PowerShell example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The PowerShell examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in PowerShell. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Kotlin / JVM</h2><p>The first request appears beside this guide. Open each step for its Kotlin / JVM client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Kotlin / JVM example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Kotlin / JVM example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Kotlin / JVM example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Kotlin / JVM example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Kotlin / JVM examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Kotlin / JVM. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Swift / server</h2><p>The first request appears beside this guide. Open each step for its Swift / server client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Swift / server example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Swift / server example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Swift / server example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Swift / server example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Swift / server examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Swift / server. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<h2>Build this sequence in Rust</h2><p>The first request appears beside this guide. Open each step for its Rust client, payload and response fields.</p><div class=\"docs-step\"><span>01</span><div><h3>Book a shipment</h3><a href=\"#post-shipment\" data-topic=\"post-shipment\">Open Rust example →</a></div></div><div class=\"docs-step\"><span>02</span><div><h3>Retrieve shipment & labels</h3><a href=\"#get-shipment-shipment-id\" data-topic=\"get-shipment-shipment-id\">Open Rust example →</a></div></div><div class=\"docs-step\"><span>03</span><div><h3>Retrieve tracking events</h3><a href=\"#get-shipment-shipment-id-tracking-events\" data-topic=\"get-shipment-shipment-id-tracking-events\">Open Rust example →</a></div></div><div class=\"docs-step\"><span>04</span><div><h3>Find invoices by shipment</h3><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\" data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\">Open Rust example →</a></div></div><h3>Completion & handling</h3><p>Booking returns HTTP 202 and id. Retrieve the shipment until processing finishes. Reuse unique_id for the same shipment intent. Failed or cancelled bookings permit a new booking under the same ID.</p><div class=\"doc-callout\">Complete polling scripts are available under the JavaScript and Python pills. The Rust examples issue individual requests.</div><p class=\"portal-example-reference\"><a href=\"#post-shipment\">Open endpoint</a></p>","introduction":"Showing the first request in Rust. Use the linked operations to build the complete sequence. Complete polling scripts are available in Node.js and Python. Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[],"legacy_paths":"/developers/workflows/booking-workflow/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Complete workflows","rich_content":"","section_slug":"booking-workflow","section_title":"Book → labels → tracking","summary":"Complete workflows"},{"code_languages":[],"content_blocks":[],"legacy_paths":"/developers/api/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"API reference","rich_content":"<p>Choose an operation to view its request client, fields and response definitions together.</p><div class=\"api-index\"><section><h2>Rates & services</h2><a data-topic=\"post-rate\" href=\"#post-rate\"><span class=\"nav-method\">POST</span>Request shipping rates</a><a data-topic=\"get-rate-rate-id\" href=\"#get-rate-rate-id\"><span class=\"nav-method\">GET</span>Retrieve rate results</a><a data-topic=\"get-services\" href=\"#get-services\"><span class=\"nav-method\">GET</span>List available services</a><a data-topic=\"post-freight-class-calculate\" href=\"#post-freight-class-calculate\"><span class=\"nav-method\">POST</span>Calculate freight class</a></section><section><h2>Booking & labels</h2><a data-topic=\"post-shipment\" href=\"#post-shipment\"><span class=\"nav-method\">POST</span>Book a shipment</a><a data-topic=\"get-shipment-shipment-id\" href=\"#get-shipment-shipment-id\"><span class=\"nav-method\">GET</span>Retrieve shipment & labels</a><a data-topic=\"delete-shipment-shipment-id\" href=\"#delete-shipment-shipment-id\"><span class=\"nav-method\">DELETE</span>Cancel a shipment</a></section><section><h2>Tracking</h2><a data-topic=\"get-shipment-shipment-id-tracking-events\" href=\"#get-shipment-shipment-id-tracking-events\"><span class=\"nav-method\">GET</span>Retrieve tracking events</a></section><section><h2>Pickups</h2><a data-topic=\"get-shipment-shipment-id-schedule\" href=\"#get-shipment-shipment-id-schedule\"><span class=\"nav-method\">GET</span>Check pickup schedule</a><a data-topic=\"post-shipment-shipment-id-schedule\" href=\"#post-shipment-shipment-id-schedule\"><span class=\"nav-method\">POST</span>Schedule a pickup</a><a data-topic=\"delete-shipment-shipment-id-schedule\" href=\"#delete-shipment-shipment-id-schedule\"><span class=\"nav-method\">DELETE</span>Cancel a pickup</a><a data-topic=\"post-shipment-schedule-validate\" href=\"#post-shipment-schedule-validate\"><span class=\"nav-method\">POST</span>Validate pickup availability</a></section><section><h2>Customs</h2><a data-topic=\"post-shipment-hts-validate\" href=\"#post-shipment-hts-validate\"><span class=\"nav-method\">POST</span>Validate HTS codes</a><a data-topic=\"post-shipment-regulations-validate\" href=\"#post-shipment-regulations-validate\"><span class=\"nav-method\">POST</span>Validate product regulations</a><a data-topic=\"get-shipment-intended-use-details\" href=\"#get-shipment-intended-use-details\"><span class=\"nav-method\">GET</span>Get intended-use details</a><a data-topic=\"get-shipment-citation-code-details\" href=\"#get-shipment-citation-code-details\"><span class=\"nav-method\">GET</span>Get citation-code details</a></section><section><h2>Dispatch</h2><a data-topic=\"post-manifest\" href=\"#post-manifest\"><span class=\"nav-method\">POST</span>Request a manifest</a><a data-topic=\"get-manifest-manifest-id\" href=\"#get-manifest-manifest-id\"><span class=\"nav-method\">GET</span>Retrieve a manifest</a></section><section><h2>Finance</h2><a data-topic=\"get-finance-payment-methods\" href=\"#get-finance-payment-methods\"><span class=\"nav-method\">GET</span>List payment methods</a><a data-topic=\"get-finance-payment-method-payment-method-id-available-balances\" href=\"#get-finance-payment-method-payment-method-id-available-balances\"><span class=\"nav-method\">GET</span>Check available balances</a><a data-topic=\"post-finance-reload-prepaid-balance\" href=\"#post-finance-reload-prepaid-balance\"><span class=\"nav-method\">POST</span>Reload prepaid balance</a><a data-topic=\"get-finance-documents\" href=\"#get-finance-documents\"><span class=\"nav-method\">GET</span>List financial documents</a><a data-topic=\"get-finance-document-document-id\" href=\"#get-finance-document-document-id\"><span class=\"nav-method\">GET</span>Retrieve a financial document</a><a data-topic=\"get-finance-invoices-for-shipment-id-shipment-id\" href=\"#get-finance-invoices-for-shipment-id-shipment-id\"><span class=\"nav-method\">GET</span>Find invoices by shipment</a><a data-topic=\"get-finance-invoices-for-transaction-number-transaction-number\" href=\"#get-finance-invoices-for-transaction-number-transaction-number\"><span class=\"nav-method\">GET</span>Find invoices by transaction</a></section></div>","section_slug":"api","section_title":"API reference","summary":"25 operations · 22 paths"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/rate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/rate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/rate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/rate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/rate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/rate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/rate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/rate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/rate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-rate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/rate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Request shipping rates</h2><div class=\"field-description\">Request a rate estimate.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Send shipment details. Omit services to request all enabled services, or supply explicit service IDs. HTTP 202 returns request_id. Preserve that ID and retrieve GET /rate/{rate_id}. This request estimates rates and does not book a shipment.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>services</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of service IDs for which to get rates. If not provided then all services will be queried for rates.</p><div class=\"field-children\"><p class=\"field-description\">List of service IDs for which to get rates. If not provided then all services will be queried for rates.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>excluded_services</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Excluded list of service IDs for which to ignore rates from.</p><div class=\"field-children\"><p class=\"field-description\">Excluded list of service IDs for which to ignore rates from.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>details</code><span class=\"field-type\">ShippingDetails</span></div></summary><p class=\"field-description\">Details on a shipment.</p><div class=\"field-children\"><p class=\"field-description\">Details on a shipment.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>origin</code><span class=\"field-type\">Origin</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>destination</code><span class=\"field-type\">Destination</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Combined structure</h3><details class=\"field-item\"><summary>Structure 1 · Establishment</summary><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary>Structure 2</summary><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>signature_requirement</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Whether a signature is required for delivery.</p><p class=\"field-type\">Values: <code>not-required</code>, <code>required</code>, <code>adult-required</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>expected_ship_date</code><span class=\"field-type\">Date</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_type</code><span class=\"field-type\">PackagingType</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>pallet</code>, <code>package</code>, <code>courier-pak</code>, <code>envelope</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packaging_properties</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Choose one structure</h3><details class=\"field-item\"><summary>Structure 1 · PackagingPallet</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>pallet_type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The pallet types.</p><p class=\"field-type\">Values: <code>ltl</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_stackable_pallets</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Pallets are stackable.</p><p class=\"field-type\">example: <code>true</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>dangerous_goods</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The shipment's dangerous goods. Empty if it does not contain dangerous goods.</p><p class=\"field-type\">Values: <code>limited-quantity</code>, <code>exemption-500-kg</code>, <code>fully-regulated</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">DangerousGoodsDetails</span></div></summary><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-children\"><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_group</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>emergency_contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>emergency_contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallets</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of values</p><div class=\"field-children\"><h3>Choose one structure</h3><details class=\"field-item\"><summary>Structure 1 · LTLPallet</summary><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallet_service_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-children\"><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">If limited access delivery the type of delivery.</p><p class=\"field-type\">Values: <code>construction-site</code>, <code>fair</code>, <code>farm</code>, <code>mall</code>, <code>mini-storage-unit</code>, <code>place-of-worship</code>, <code>school</code>, <code>secured-location</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_other_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Provided if the limited_access_type is 'other'.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>in_bond</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If the shipment requires a US in-bond service.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>in_bond_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details for in bond if needed.</p><div class=\"field-children\"><p class=\"field-description\">Details for in bond if needed.</p><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>immediate-exportation</code>, <code>transportation-and-exportation</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Address of the warehouse or carrier that will cancel the US bond.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_method</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Which contact method to utilize.</p><p class=\"field-type\">Values: <code>email-address</code>, <code>phone-number</code>, <code>fax-number</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_email_address</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>appointment_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>protect_from_freeze</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_pickup</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div></div></details></div></details><details class=\"field-item\"><summary>Structure 2 · PackagingPackage</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Indicates the shipment's packages contain dangerous goods. When true, dangerous_goods_details must also be provided.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">PackageDangerousGoodsDetails</span></div></summary><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-children\"><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packages</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>measurements</code><span class=\"field-type\">Box</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>special_handling_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"field-item\"><summary>Structure 3 · PackagingCourierPak</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Courier paks contain dangerous goods.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>courier_paks</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>weight</code><span class=\"field-type\">Weight</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"field-item\"><summary>Structure 4 · PackagingEnvelope</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>insurance</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-children\"><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>internal</code>, <code>carrier</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>total_cost</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>reference_codes</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Reference codes for the shipment.</p><div class=\"field-children\"><p class=\"field-description\">Reference codes for the shipment.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_classification</code><span class=\"field-type\">ShipmentClassification</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>B2B</code>, <code>B2C</code>, <code>C2B</code>, <code>C2C</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>products</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><div class=\"field-children\"><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>hs_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The 10 digit HTS Code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>hsverified</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nDefaults to false. if true, `hs_code` must be picked up from the recommended ones provided by `hts-validate` api`.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the name of the customs product which you are shipping.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_hscode</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided hscode (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided description (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country_of_origin</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p><p class=\"field-type\">Values: <code>SKU</code>, <code>MODEL_NUMBER</code>, <code>SERIAL_NUMBER</code>, <code>ALTERNATE_ID</code>, <code>UPC</code>, <code>GTIN</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cpsc_regulated</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(UPDATED in 2.10.0)** If product is CPSC Regulated, we need to toggle this to true, only applicable to US Destined Shipments.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_registered_product_information</code><span class=\"field-type\">CPSCRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>certifier_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The CPSC issued ID of the party certifying the product.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product's CPSC Registered Product ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>version_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Version of the certificate for this product.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_non_registered_product_information</code><span class=\"field-type\">CPSCNonRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>product_certificate_declaration</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>certificate_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>CPC</code>, <code>GCC</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>manufacturer_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>lot_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>citation_details</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>point_of_contact</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_certificate_not_required_information</code><span class=\"field-type\">CPSCCertificateNotRequiredInformation</span></div></summary><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>disclaimer_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Reason code for exemption `A` | `B`.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>num_units</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>1</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>unit_price</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The description of the product. Maximum length of 35 characters for UPS</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cusma_included</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. If true, you certify the goods meet CUSMA (USMCA) rules of origin and that a valid certification of origin is provided.\n\nIf the carrier accepts paperless_customs_documents, a valid CUSMA document with type 'cusma-form' must be included in the paperless_customs_documents.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>non_auto_parts</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain auto parts, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does **not** contain auto parts.\nThis will avoid any tariffs related to auto parts.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to auto parts.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>completed_kitchen_cabinets_or_vanities</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain completed kitchen cabinets or vanities, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does contain completed kitchen cabinets or vanities.\nThis will avoid any tariffs related to not completed kitchen cabinets or vanities.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to completed kitchen cabinets or vanities.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>fda_regulated</code><span class=\"field-type\">enum</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">**(NEW in 2.6.2)** Please specify \"yes\" if this product is regulated by the U.S. Food and Drug Administration (FDA) and \"no\" if it is not.\n\nIf your shipment contains an FDA regulated product, some carriers will not accept it.\nBy specifying \"yes\", we can provide rates and book shipments only for carriers that will accept FDA regulated products.\n</p><p class=\"field-type\">Values: <code>yes</code>, <code>no</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_composition_allocation</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** If your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** If your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-item\"><div class=\"field-heading\"><code>provided</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. Set to true to specify steel/aluminum/copper allocation percentages.\n\nDoes not affect rates if you have set `product_composition_allocation_zero` to true.\n\nIf both this field and `product_composition_allocation_zero` are omitted or false, then you are not specifying any steel/aluminum/copper allocation percentages, regardless of the percentage values in this object.\nAs a result, you may receive higher customs charges than necessary.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>steel_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains steel, specify the percentage of steel that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>aluminum_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains aluminum, specify the percentage of aluminum that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>copper_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains copper, specify the percentage of copper that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>product_composition_allocation_zero</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** Optional field that defaults to false. If true, you certify that your product's composition allocation percentages are all 0%.\n\nFor simplicity, you may choose to ignore this field and always explicitly specify your product's composition allocation percentages, as long as you specify `product_composition_allocation.provided` true.\n\nIf this field is true, the `product_composition_allocation` object will not affect rates. However, if you specify a non-zero allocation percentage, you will receive an error.\n</p></div></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>request_guaranteed_customs_charges</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If false or omitted, customs charges will be estimates only. If true, guaranteed customs charges will be requested.\nIf a rate has is_rate_guaranteed true, then all of its customs charges are guaranteed - provided the product information, description and HTS codes are correct.\n</p></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"services\": {\n \"type\": \"array\",\n \"description\": \"List of service IDs for which to get rates. If not provided then all services will be queried for rates.\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"excluded_services\": {\n \"type\": \"array\",\n \"description\": \"Excluded list of service IDs for which to ignore rates from.\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"details\": {\n \"$ref\": \"#/components/schemas/ShippingDetails\"\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 202 · Response with the rate ID that can be used to poll for and retrieve the rate.</summary><p class=\"field-description\">Response with the rate ID that can be used to poll for and retrieve the rate.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>request_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The rate ID.</p></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"202\": {\n \"description\": \"Response with the rate ID that can be used to poll for and retrieve the rate.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"request_id\": {\n \"type\": \"string\",\n \"description\": \"The rate ID.\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-rate/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Rates & services","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/rate</div>","section_slug":"post-rate","section_title":"Request shipping rates","summary":"API reference · Rates & services"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-rate-rate-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/rate/REPLACE_WITH_RATE_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Retrieve rate results</h2><div class=\"field-description\">Retrieve a requested rate. Also includes details on the number of pending rate lookups to perform if any.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 200 also covers incomplete lookups. Check status.done, status.total and status.complete. Use rates only according to your policy for partial results. Preserve Money.currency and the string Money.value. Ignore transit_time_days when transit_time_not_available is true. Check valid_until before booking.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>rate_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The rate ID to retrieve details on.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"rate_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The rate ID to retrieve details on.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · The results of the rate estimate request. Includes status information if additional lookups need to be performed.</summary><p class=\"field-description\">The results of the rate estimate request. Includes status information if additional lookups need to be performed.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>status</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Status of the rate lookup request.</p><div class=\"field-children\"><p class=\"field-description\">Status of the rate lookup request.</p><div class=\"field-item\"><div class=\"field-heading\"><code>done</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the rates search has completed.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>total</code><span class=\"field-type\">integer</span></div><p class=\"field-description\">The total number of services that rates will be searched with.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>complete</code><span class=\"field-type\">integer</span></div><p class=\"field-description\">The number of services that have had rates searched on.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>rates</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Rate estimates.</p><div class=\"field-children\"><p class=\"field-description\">Rate estimates.</p><p class=\"field-type\">Array of Rate</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>carrier_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the carrier.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the service.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The ID of the service, utilized for booking.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>valid_until</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>total</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>base</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>surcharges</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">An array of surcharges.</p><div class=\"field-children\"><p class=\"field-description\">An array of surcharges.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The surcharge type.</p><p class=\"field-type\">example: <code>fuel</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>taxes</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">An array of taxes.</p><div class=\"field-children\"><p class=\"field-description\">An array of taxes.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The tax type.</p><p class=\"field-type\">example: <code>fuel</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>transit_time_days</code><span class=\"field-type\">integer</span></div><p class=\"field-description\">The number of days that the shipment will take to reach the destination.</p><p class=\"field-type\">example: <code>5</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>transit_time_not_available</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Some carriers may not provide a valid transit time. If this value is true then transit_time_days should be ignored regardless of the value provided.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>paperless</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.0)** If true then the rate supports a paperless customs invoice. With certain carriers, you may upload additional paperless customs documents when booking the shipment, such as a CUSMA Certificate, by providing paperless_customs_documents when booking.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_charge_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** If present, contains data about the customs charges for a DDP shipment (shipper pays the customs charges).</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** If present, contains data about the customs charges for a DDP shipment (shipper pays the customs charges).</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>duties_and_taxes_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The surcharge types that correspond to customs duties and taxes charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional duties and taxes charges - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">The surcharge types that correspond to customs duties and taxes charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional duties and taxes charges - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>guarantee_fee_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** When is_rate_guaranteed is true, these surcharge types correspond to the additional fees to guarantee all customs charges.\nShould be empty when is_rate_guaranteed is false.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** When is_rate_guaranteed is true, these surcharge types correspond to the additional fees to guarantee all customs charges.\nShould be empty when is_rate_guaranteed is false.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>carrier_and_government_fees_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** The surcharge types that correspond to customs carrier and government fees.\nThis includes everything related to the customs clearance of your shipment such as clearance, brokerage, FDA, disbursement, MPF, line item, PGA etc.\n\nIf is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional charges on the clearance of this shipment - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** The surcharge types that correspond to customs carrier and government fees.\nThis includes everything related to the customs clearance of your shipment such as clearance, brokerage, FDA, disbursement, MPF, line item, PGA etc.\n\nIf is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional charges on the clearance of this shipment - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>processing_fees_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The surcharge types that correspond to customs processing fees charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional processing fees - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">The surcharge types that correspond to customs processing fees charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional processing fees - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>is_rate_guaranteed</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If true, then all customs charges are guaranteed: you will not receive any additional customs charges - provided the product information, description and HTS codes are correct.\nThis encompasses all surcharge types belonging to the customs_charge_data fields.\n\nTo receive guaranteed customs charges, you must specify customs_data.request_guaranteed_customs_charges true when requesting a rate or booking a shipment.\n</p></div></div></details></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"The results of the rate estimate request. Includes status information if additional lookups need to be performed.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"object\",\n \"description\": \"Status of the rate lookup request.\",\n \"properties\": {\n \"done\": {\n \"type\": \"boolean\",\n \"description\": \"If true then the rates search has completed.\"\n },\n \"total\": {\n \"type\": \"integer\",\n \"description\": \"The total number of services that rates will be searched with.\"\n },\n \"complete\": {\n \"type\": \"integer\",\n \"description\": \"The number of services that have had rates searched on.\"\n }\n }\n },\n \"rates\": {\n \"type\": \"array\",\n \"description\": \"Rate estimates.\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Rate\"\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-rate-rate-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Rates & services","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/rate/{rate_id}</div>","section_slug":"get-rate-rate-id","section_title":"Retrieve rate results","summary":"API reference · Rates & services"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/services\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/services', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/services', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/services');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/services\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/services\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/services')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/services'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/services\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/services\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-services\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/services\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>List available services</h2><div class=\"field-description\">Get the services available.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Returns an object containing services, an array with id, carrier_name and service_name. These are the account service IDs used for rating filters and booking. The documented response does not include carrier_id. Do not invent a carrier ID for pickup validation or manifests.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Services available to the customer.</summary><p class=\"field-description\">Services available to the customer.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>services</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Service IDs and descriptions.</p><div class=\"field-children\"><p class=\"field-description\">Service IDs and descriptions.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>carrier_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Services available to the customer.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"services\": {\n \"type\": \"array\",\n \"description\": \"Service IDs and descriptions.\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"carrier_name\": {\n \"type\": \"string\"\n },\n \"service_name\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-services/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Rates & services","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/services</div>","section_slug":"get-services","section_title":"List available services","summary":"API reference · Rates & services"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/freight-class/calculate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/freight-class/calculate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/freight-class/calculate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/freight-class/calculate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/freight-class/calculate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/freight-class/calculate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/freight-class/calculate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/freight-class/calculate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/freight-class/calculate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/freight-class/calculate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/freight-class/calculate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/freight-class/calculate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-freight-class-calculate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/freight-class/calculate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"box\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 500\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 48,\n \"w\": 40,\n \"h\": 48\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Calculate freight class</h2><div class=\"field-description\">Calculate freight class for pallet dimensions.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Supply box.weight and box.cuboid with accurate loaded pallet measurements and units. The response freight_class is a string. Confirm commodity and carrier requirements before using the calculated class in a pallet request. The pallet packaging model uses packaging_type pallet and the literal pallet_type value ltl.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#rate-workflow\" data-topic=\"rate-workflow\">Rate → completed results</a><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>box</code><span class=\"field-type\">Box</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>weight</code><span class=\"field-type\">Weight</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>unit</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit that the weight is in.</p><p class=\"field-type\">Values: <code>kg</code>, <code>lb</code>, <code>g</code>, <code>oz</code></p><p class=\"field-type\">example: <code>lb</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">number</span></div><p class=\"field-description\">Weight value in the unit.</p><p class=\"field-type\">example: <code>2.95</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cuboid</code><span class=\"field-type\">Cuboid</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>unit</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit that the dimension is in.</p><p class=\"field-type\">Values: <code>mm</code>, <code>cm</code>, <code>m</code>, <code>in</code>, <code>ft</code></p><p class=\"field-type\">example: <code>ft</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>l</code><span class=\"field-type\">number</span></div><p class=\"field-description\">Length value in the unit.</p><p class=\"field-type\">example: <code>5</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>w</code><span class=\"field-type\">number</span></div><p class=\"field-description\">Width value in the unit.</p><p class=\"field-type\">example: <code>5</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>h</code><span class=\"field-type\">number</span></div><p class=\"field-description\">Height value in the unit.</p><p class=\"field-type\">example: <code>5</code></p></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"box\": {\n \"$ref\": \"#/components/schemas/Box\"\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Freight class calculated.</summary><p class=\"field-description\">Freight class calculated.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>freight_class</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Freight class calculated.</p><p class=\"field-type\">example: <code>50</code></p></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Freight class calculated.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"freight_class\": {\n \"type\": \"string\",\n \"description\": \"Freight class calculated.\",\n \"example\": \"50\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-freight-class-calculate/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Rates & services","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/freight-class/calculate</div>","section_slug":"post-freight-class-calculate","section_title":"Calculate freight class","summary":"API reference · Rates & services"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"unique_id\": \"REPLACE_WITH_STABLE_ORDER_SHIPMENT_ID\",\n \"payment_method_id\": \"REPLACE_WITH_ACCOUNT_PAYMENT_ID\",\n \"service_id\": \"REPLACE_WITH_RETURNED_SERVICE_ID\",\n \"details\": {\n \"origin\": {\n \"name\": \"Example Warehouse\",\n \"address\": {\n \"address_line_1\": \"200 University Avenue West\",\n \"city\": \"Waterloo\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"N2L 3G1\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Shipping Team\",\n \"phone_number\": {\n \"number\": \"5195550100\"\n },\n \"email_addresses\": [\n \"shipping@example.com\"\n ]\n },\n \"destination\": {\n \"name\": \"Example Customer\",\n \"address\": {\n \"address_line_1\": \"100 Queen Street West\",\n \"city\": \"Toronto\",\n \"region\": \"ON\",\n \"country\": \"CA\",\n \"postal_code\": \"M5H 2N2\"\n },\n \"residential\": false,\n \"tailgate_required\": false,\n \"contact_name\": \"Receiving Team\",\n \"phone_number\": {\n \"number\": \"4165550100\"\n },\n \"email_addresses\": [\n \"receiving@example.com\"\n ],\n \"ready_at\": {\n \"hour\": 9,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"signature_requirement\": \"not-required\"\n },\n \"expected_ship_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"packaging_type\": \"package\",\n \"packaging_properties\": {\n \"packages\": [\n {\n \"measurements\": {\n \"weight\": {\n \"unit\": \"lb\",\n \"value\": 5\n },\n \"cuboid\": {\n \"unit\": \"in\",\n \"l\": 12,\n \"w\": 10,\n \"h\": 8\n }\n },\n \"description\": \"Printed books\",\n \"special_handling_required\": false\n }\n ],\n \"includes_return_label\": false,\n \"has_dangerous_goods\": false\n }\n },\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Book a shipment.</h2><div class=\"field-description\">Book a shipment.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Supply the selected service_id, account payment_method_id, shipping details and a stable unique_id of at most 128 characters. unique_id comparisons ignore case. HTTP 202 returns id and previously_created. A matching in-progress or successful booking is reused. A failed or cancelled booking permits creation under the same unique_id. Preserve the returned shipment ID before further processing. Include pickup_details for courier service or dispatch_details for pallet dispatch. Customs invoice information is required for international shipments.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Book → labels → tracking</a><a href=\"#first-shipment\" data-topic=\"first-shipment\">Your first shipment</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><div class=\"field-item\"><div class=\"field-heading\"><code>unique_id</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Maximum length of 128 characters. Uppercase and lowercase characters are considered equal for comparisons. Used to uniquely identify a shipment. If the unique_id matches a previously created shipment that is in the process of booking or booked successfully then a new shipment will NOT be created and the ID for the previously created shipment will be returned. If the previously created shipment had an error during booking or was cancelled then a new shipment with the unique_id will be created and unique_id will be associated with this new shipment.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>payment_method_id</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Payment method to use, obtained from /finance/payment-methods.\n\n**(UPDATED in 2.7.0)** If you have activated Prepaid Shipping in the customer portal, you must use your prepaid payment method to book shipments.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>customs_and_duties_payment_method_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.6.0)** Payment method to use to pay for the customs charges when booking a DDP shipment (shipper pays the customs charges). If omitted, payment_method_id will be used to pay for all charges including customs charges.\n\nIf you are booking a DDP shipment and payment_method_id is your Net Terms payment method, then you must specify a credit card payment method in this field to pay for the customs charges.\n\nObtained from /finance/payment-methods.\n\n**(UPDATED in 2.7.0)** If you have activated Prepaid Shipping in the customer portal, you must use your prepaid payment method to book shipments.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_id</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Service to book with.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>details</code><span class=\"field-type\">ShippingDetails</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Details on a shipment.</p><div class=\"field-children\"><p class=\"field-description\">Details on a shipment.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>origin</code><span class=\"field-type\">Origin</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>destination</code><span class=\"field-type\">Destination</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Combined structure</h3><details class=\"field-item\"><summary>Structure 1 · Establishment</summary><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary>Structure 2</summary><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>signature_requirement</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Whether a signature is required for delivery.</p><p class=\"field-type\">Values: <code>not-required</code>, <code>required</code>, <code>adult-required</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>expected_ship_date</code><span class=\"field-type\">Date</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_type</code><span class=\"field-type\">PackagingType</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>pallet</code>, <code>package</code>, <code>courier-pak</code>, <code>envelope</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packaging_properties</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Choose one structure</h3><details class=\"field-item\"><summary>Structure 1 · PackagingPallet</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>pallet_type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The pallet types.</p><p class=\"field-type\">Values: <code>ltl</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_stackable_pallets</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Pallets are stackable.</p><p class=\"field-type\">example: <code>true</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>dangerous_goods</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The shipment's dangerous goods. Empty if it does not contain dangerous goods.</p><p class=\"field-type\">Values: <code>limited-quantity</code>, <code>exemption-500-kg</code>, <code>fully-regulated</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">DangerousGoodsDetails</span></div></summary><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-children\"><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_group</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>emergency_contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>emergency_contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallets</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of values</p><div class=\"field-children\"><h3>Choose one structure</h3><details class=\"field-item\"><summary>Structure 1 · LTLPallet</summary><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallet_service_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-children\"><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">If limited access delivery the type of delivery.</p><p class=\"field-type\">Values: <code>construction-site</code>, <code>fair</code>, <code>farm</code>, <code>mall</code>, <code>mini-storage-unit</code>, <code>place-of-worship</code>, <code>school</code>, <code>secured-location</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_other_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Provided if the limited_access_type is 'other'.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>in_bond</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If the shipment requires a US in-bond service.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>in_bond_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details for in bond if needed.</p><div class=\"field-children\"><p class=\"field-description\">Details for in bond if needed.</p><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>immediate-exportation</code>, <code>transportation-and-exportation</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Address of the warehouse or carrier that will cancel the US bond.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_method</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Which contact method to utilize.</p><p class=\"field-type\">Values: <code>email-address</code>, <code>phone-number</code>, <code>fax-number</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_email_address</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>appointment_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>protect_from_freeze</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_pickup</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div></div></details></div></details><details class=\"field-item\"><summary>Structure 2 · PackagingPackage</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Indicates the shipment's packages contain dangerous goods. When true, dangerous_goods_details must also be provided.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">PackageDangerousGoodsDetails</span></div></summary><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-children\"><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packages</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>measurements</code><span class=\"field-type\">Box</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>special_handling_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"field-item\"><summary>Structure 3 · PackagingCourierPak</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Courier paks contain dangerous goods.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>courier_paks</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>weight</code><span class=\"field-type\">Weight</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"field-item\"><summary>Structure 4 · PackagingEnvelope</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>insurance</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-children\"><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>internal</code>, <code>carrier</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>total_cost</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>reference_codes</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Reference codes for the shipment.</p><div class=\"field-children\"><p class=\"field-description\">Reference codes for the shipment.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_classification</code><span class=\"field-type\">ShipmentClassification</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>B2B</code>, <code>B2C</code>, <code>C2B</code>, <code>C2C</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>products</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><div class=\"field-children\"><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>hs_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The 10 digit HTS Code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>hsverified</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nDefaults to false. if true, `hs_code` must be picked up from the recommended ones provided by `hts-validate` api`.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the name of the customs product which you are shipping.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_hscode</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided hscode (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided description (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country_of_origin</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p><p class=\"field-type\">Values: <code>SKU</code>, <code>MODEL_NUMBER</code>, <code>SERIAL_NUMBER</code>, <code>ALTERNATE_ID</code>, <code>UPC</code>, <code>GTIN</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cpsc_regulated</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(UPDATED in 2.10.0)** If product is CPSC Regulated, we need to toggle this to true, only applicable to US Destined Shipments.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_registered_product_information</code><span class=\"field-type\">CPSCRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>certifier_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The CPSC issued ID of the party certifying the product.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product's CPSC Registered Product ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>version_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Version of the certificate for this product.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_non_registered_product_information</code><span class=\"field-type\">CPSCNonRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>product_certificate_declaration</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>certificate_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>CPC</code>, <code>GCC</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>manufacturer_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>lot_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>citation_details</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>point_of_contact</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_certificate_not_required_information</code><span class=\"field-type\">CPSCCertificateNotRequiredInformation</span></div></summary><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>disclaimer_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Reason code for exemption `A` | `B`.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>num_units</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>1</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>unit_price</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The description of the product. Maximum length of 35 characters for UPS</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cusma_included</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. If true, you certify the goods meet CUSMA (USMCA) rules of origin and that a valid certification of origin is provided.\n\nIf the carrier accepts paperless_customs_documents, a valid CUSMA document with type 'cusma-form' must be included in the paperless_customs_documents.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>non_auto_parts</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain auto parts, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does **not** contain auto parts.\nThis will avoid any tariffs related to auto parts.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to auto parts.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>completed_kitchen_cabinets_or_vanities</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain completed kitchen cabinets or vanities, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does contain completed kitchen cabinets or vanities.\nThis will avoid any tariffs related to not completed kitchen cabinets or vanities.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to completed kitchen cabinets or vanities.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>fda_regulated</code><span class=\"field-type\">enum</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">**(NEW in 2.6.2)** Please specify \"yes\" if this product is regulated by the U.S. Food and Drug Administration (FDA) and \"no\" if it is not.\n\nIf your shipment contains an FDA regulated product, some carriers will not accept it.\nBy specifying \"yes\", we can provide rates and book shipments only for carriers that will accept FDA regulated products.\n</p><p class=\"field-type\">Values: <code>yes</code>, <code>no</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_composition_allocation</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** If your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** If your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-item\"><div class=\"field-heading\"><code>provided</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. Set to true to specify steel/aluminum/copper allocation percentages.\n\nDoes not affect rates if you have set `product_composition_allocation_zero` to true.\n\nIf both this field and `product_composition_allocation_zero` are omitted or false, then you are not specifying any steel/aluminum/copper allocation percentages, regardless of the percentage values in this object.\nAs a result, you may receive higher customs charges than necessary.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>steel_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains steel, specify the percentage of steel that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>aluminum_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains aluminum, specify the percentage of aluminum that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>copper_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains copper, specify the percentage of copper that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>product_composition_allocation_zero</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** Optional field that defaults to false. If true, you certify that your product's composition allocation percentages are all 0%.\n\nFor simplicity, you may choose to ignore this field and always explicitly specify your product's composition allocation percentages, as long as you specify `product_composition_allocation.provided` true.\n\nIf this field is true, the `product_composition_allocation` object will not affect rates. However, if you specify a non-zero allocation percentage, you will receive an error.\n</p></div></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>request_guaranteed_customs_charges</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If false or omitted, customs charges will be estimates only. If true, guaranteed customs charges will be requested.\nIf a rate has is_rate_guaranteed true, then all of its customs charges are guaranteed - provided the product information, description and HTS codes are correct.\n</p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_invoice</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Customs invoice info. Required for international shipments.</p><div class=\"field-children\"><p class=\"field-description\">Customs invoice info. Required for international shipments.</p><div class=\"field-item\"><div class=\"field-heading\"><code>source</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The source of the customs invoice: details provided, will provide in person. In person only available for pallet shipments.\n</p><p class=\"field-type\">Values: <code>details</code>, <code>in-person</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>broker</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Information on the customs invoice broker.</p><div class=\"field-children\"><p class=\"field-description\">Information on the customs invoice broker.</p><div class=\"field-item\"><div class=\"field-heading\"><code>use_carrier</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true, the carrier will be used as the broker. Can only be true for courier shipments.\n\n**(UPDATED in 2.6.0)** For package and courier pak shipments from Canada to the US, if the customs products are valued at $800 USD or less, then use_carrier must be true.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Name of the party acting as the broker. Required if use_carrier is false.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>account_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The customer's account number with the broker</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>fax_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>email_address</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>usmca_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>fda_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Customs invoice details.</p><div class=\"field-children\"><p class=\"field-description\">Customs invoice details.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>tax_recipient</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Who will pay the customs charges.\n\n**(UPDATED in 2.6.0)** For package and courier pak shipments from Canada to the US:\n- If the tax-recipient type is 'shipper', then customs_data must be provided in the ShippingDetails.\n- If the tax-recipient type is 'receiver', then customs_data must be omitted from the ShippingDetails.\n</p><p class=\"field-type\">Values: <code>shipper</code>, <code>receiver</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>shipper_tax_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>receiver_tax_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>third_party_tax_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>other_tax_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>reason_for_export</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>gift</code>, <code>repair-warranty</code>, <code>commercial-sample</code>, <code>return-shipment</code>, <code>commercially-sold-goods</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>additional_remarks</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>comments</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Comments that will appear on the generated customs invoice document.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>products</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>product_name</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for EU and US Destined Shipments</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for EU and US Destined Shipments</p><p class=\"field-type\">Values: <code>SKU</code>, <code>MODEL_NUMBER</code>, <code>SERIAL_NUMBER</code>, <code>ALTERNATE_ID</code>, <code>UPC</code>, <code>GTIN</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>merchant_product_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>non_standardised_manufacturer_product_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>standardised_manufacturer_product_identifier</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cpsc_regulated</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(UPDATED in 2.10.0)** If product is CPSC Regulated, we need to toggle this to true, only applicable to US Destined Shipments.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_registered_product_information</code><span class=\"field-type\">CPSCRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>certifier_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The CPSC issued ID of the party certifying the product.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product's CPSC Registered Product ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>version_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Version of the certificate for this product.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_non_registered_product_information</code><span class=\"field-type\">CPSCNonRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>product_certificate_declaration</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>certificate_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>CPC</code>, <code>GCC</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>manufacturer_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>lot_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>citation_details</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>point_of_contact</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_certificate_not_required_information</code><span class=\"field-type\">CPSCCertificateNotRequiredInformation</span></div></summary><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-children\"><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-item\"><div class=\"field-heading\"><code>disclaimer_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Reason code for exemption `A` | `B`.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>intended_use_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Refer to `intended-use-details` API for accepted values.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>weight</code><span class=\"field-type\">Weight</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>unit</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit that the weight is in.</p><p class=\"field-type\">Values: <code>kg</code>, <code>lb</code>, <code>g</code>, <code>oz</code></p><p class=\"field-type\">example: <code>lb</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">number</span></div><p class=\"field-description\">Weight value in the unit.</p><p class=\"field-type\">example: <code>2.95</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>hs_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.6.0)** HS/HTS Code. Shipments entering the US require a 10 digit HTS Code. Shipments entering the EU require an HS Code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>hsverified</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nDefaults to false. if true, `hs_code` must be picked up from the recommended ones provided by `hts-validate` api`.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_hscode</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided hscode (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided description (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country_of_origin</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>num_units</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>1</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>unit_price</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The description of the product. Maximum length of 35 characters for UPS</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cusma_included</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US.\n\nIf true, you certify the goods meet CUSMA (USMCA) rules of origin and that a valid certification of origin is provided. If the carrier accepts paperless_customs_documents, a valid CUSMA document with type 'cusma-form' must be included in the paperless_customs_documents.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>non_auto_parts</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\n\nIf the product's HTS Code implies it may contain auto parts, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does **not** contain auto parts.\nThis will avoid any tariffs related to auto parts.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to auto parts.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>fda_regulated</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">**(NEW in 2.6.2)** Applies only to package and courier pak shipments from Canada to the US.\nRequired for these shipments.\n\nPlease specify \"yes\" if this product is regulated by the U.S. Food and Drug Administration (FDA) and \"no\" if it is not.\n\nIf your shipment contains an FDA regulated product, some carriers will not accept it.\nBy specifying \"yes\", we can provide rates and book shipments only for carriers that will accept FDA regulated products.\n</p><p class=\"field-type\">Values: <code>yes</code>, <code>no</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_composition_allocation</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\n\nIf your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\n\nIf your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-item\"><div class=\"field-heading\"><code>provided</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. Set to true to specify steel/aluminum/copper allocation percentages.\n\nDoes not affect rates if you have set `product_composition_allocation_zero` to true.\n\nIf both this field and `product_composition_allocation_zero` are omitted or false, then you are not specifying any steel/aluminum/copper allocation percentages, regardless of the percentage values in this object.\nAs a result, you may receive higher customs charges than necessary.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>steel_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains steel, specify the percentage of steel that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>aluminum_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains aluminum, specify the percentage of aluminum that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>copper_percentage</code><span class=\"field-type\">number</span></div><p class=\"field-description\">If your product contains copper, specify the percentage of copper that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\n\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\n</p><p class=\"field-type\">minimum: <code>0</code></p><p class=\"field-type\">maximum: <code>1</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>product_composition_allocation_zero</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\n\nOptional field that defaults to false. If true, you certify that your product's composition allocation percentages are all 0%.\n\nFor simplicity, you may choose to ignore this field and always explicitly specify your product's composition allocation percentages, as long as you specify `product_composition_allocation.provided` true.\n\nIf this field is true, the `product_composition_allocation` object will not affect rates. However, if you specify a non-zero allocation percentage, you will receive an error.\n</p></div></div></div></details></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pickup_details</code><span class=\"field-type\">PickupDetails</span></div></summary><p class=\"field-description\">Courier pickup details, required if courier service utilized.</p><div class=\"field-children\"><p class=\"field-description\">Courier pickup details, required if courier service utilized.</p><div class=\"field-item\"><div class=\"field-heading\"><code>pre_scheduled_pickup</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then all other fields are ignored. Indicates that the customer has their own arrangements with the carrier for scheduling.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>pickup_location</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dispatch_details</code><span class=\"field-type\">DispatchDetails</span></div></summary><p class=\"field-description\">pallet dispatch details, required if dispatch service utilized.</p><div class=\"field-children\"><p class=\"field-description\">pallet dispatch details, required if dispatch service utilized.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>paperless_customs_documents</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** Paperless customs documents to upload to the carrier, if supported.\n\nCurrently, we support paperless customs documents for international shipments with paperless rates from FedEx Courier and UPS. Each carrier limits the number of files that can be uploaded:\n\n- FedEx Courier: up to 5 files may be uploaded.\n- UPS: up to 13 files may be uploaded.\n\nA paperless customs invoice is created automatically: it is not necessary to upload one. The paperless customs invoice does not count towards the maximum # of files that may be uploaded.\n\nSince an API request is limited to at most 6 MB, and files must be Base64 encoded, this puts an upper limit of approximately 4.5 MB (before Base64 encoding) on the total size of all files that may be uploaded in a single request.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** Paperless customs documents to upload to the carrier, if supported.\n\nCurrently, we support paperless customs documents for international shipments with paperless rates from FedEx Courier and UPS. Each carrier limits the number of files that can be uploaded:\n\n- FedEx Courier: up to 5 files may be uploaded.\n- UPS: up to 13 files may be uploaded.\n\nA paperless customs invoice is created automatically: it is not necessary to upload one. The paperless customs invoice does not count towards the maximum # of files that may be uploaded.\n\nSince an API request is limited to at most 6 MB, and files must be Base64 encoded, this puts an upper limit of approximately 4.5 MB (before Base64 encoding) on the total size of all files that may be uploaded in a single request.\n</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The document's type. Allowed types depend on the carrier.\n\nIf you have specified cusma_included true on one or more of your customs products, then you must upload a document with type 'cusma-form'.\nIf you have specified a non-zero steel/aluminum/copper allocation on one or more of your customs products, then you must upload a document with type 'product-composition-allocation-document'.\n\n**Valid document types for FedEx Courier shipments**\n\n| type | Description |\n| --------------------------------------- | ----------------------------------- |\n| certificate-of-origin | Certificate of Origin |\n| cusma-form | CUSMA Certificate |\n| customs-invoice | Customs Invoice |\n| fda-prior-notice | FDA Prior Notice |\n| lacey-act-form | Lacey Act Declaration |\n| packing-slip | Packing Slip |\n| pro-forma-invoice | Pro Forma Invoice |\n| product-composition-allocation-document | Steel/Aluminum/Copper Documentation |\n| tsca | TSCA Declaration |\n| other | Other Documents |\n\n**Valid document types for UPS shipments**\n\n| type | Description |\n| --------------------------------------- | ----------------------------------- |\n| authorization-form | Authorization Form |\n| certificate-of-origin | Certificate of Origin |\n| cusma-form | CUSMA Certificate |\n| customs-invoice | Customs Invoice |\n| declaration | Declaration |\n| export-accompanying-document | Export Accompanying Document |\n| export-license | Export License |\n| fda-prior-notice | FDA Prior Notice |\n| import-permit | Import Permit |\n| lacey-act-form | Lacey Act Declaration |\n| one-time-nafta | One Time NAFTA |\n| packing-slip | Packing Slip |\n| power-of-attorney | Power Of Attorney |\n| product-composition-allocation-document | Steel/Aluminum/Copper Documentation |\n| sed-document | SED Document |\n| shippers-letter-of-instruction | Shipper's Letter Of Instruction |\n| tsca | TSCA Declaration |\n| other | Other Documents |\n</p><p class=\"field-type\">Values: <code>cusma-form</code>, <code>product-composition-allocation-document</code>, <code>authorization-form</code>, <code>certificate-of-origin</code>, <code>customs-invoice</code>, <code>declaration</code>, <code>export-accompanying-document</code>, <code>export-license</code>, <code>fda-prior-notice</code>, <code>import-permit</code>, <code>lacey-act-form</code>, <code>one-time-nafta</code>, <code>packing-slip</code>, <code>power-of-attorney</code>, <code>pro-forma-invoice</code>, <code>sed-document</code>, <code>shippers-letter-of-instruction</code>, <code>tsca</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type_other_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">If the document's type is 'other', then this field is the document's name and is required. If the document's type is not 'other', then this field must be left empty.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>file_name</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The document's file name, including its extension. A carrier may allow specific file extensions only, and the file's contents should match its extension.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>file_base64</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The document file, encoded as Base64. The maximum total size of all files in a request is approximately 4.5 MB (before Base64 encoding).</p></div></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"required\": [\n \"unique_id\",\n \"payment_method_id\",\n \"service_id\",\n \"details\"\n ],\n \"properties\": {\n \"unique_id\": {\n \"type\": \"string\",\n \"description\": \"Maximum length of 128 characters. Uppercase and lowercase characters are considered equal for comparisons. Used to uniquely identify a shipment. If the unique_id matches a previously created shipment that is in the process of booking or booked successfully then a new shipment will NOT be created and the ID for the previously created shipment will be returned. If the previously created shipment had an error during booking or was cancelled then a new shipment with the unique_id will be created and unique_id will be associated with this new shipment.\"\n },\n \"payment_method_id\": {\n \"type\": \"string\",\n \"description\": \"Payment method to use, obtained from /finance/payment-methods.\\n\\n**(UPDATED in 2.7.0)** If you have activated Prepaid Shipping in the customer portal, you must use your prepaid payment method to book shipments.\\n\"\n },\n \"customs_and_duties_payment_method_id\": {\n \"type\": \"string\",\n \"description\": \"**(NEW in 2.6.0)** Payment method to use to pay for the customs charges when booking a DDP shipment (shipper pays the customs charges). If omitted, payment_method_id will be used to pay for all charges including customs charges.\\n\\nIf you are booking a DDP shipment and payment_method_id is your Net Terms payment method, then you must specify a credit card payment method in this field to pay for the customs charges.\\n\\nObtained from /finance/payment-methods.\\n\\n**(UPDATED in 2.7.0)** If you have activated Prepaid Shipping in the customer portal, you must use your prepaid payment method to book shipments.\\n\"\n },\n \"service_id\": {\n \"type\": \"string\",\n \"description\": \"Service to book with.\"\n },\n \"details\": {\n \"$ref\": \"#/components/schemas/ShippingDetails\"\n },\n \"customs_invoice\": {\n \"type\": \"object\",\n \"description\": \"Customs invoice info. Required for international shipments.\",\n \"required\": [\n \"source\",\n \"broker\"\n ],\n \"properties\": {\n \"source\": {\n \"type\": \"string\",\n \"description\": \"The source of the customs invoice: details provided, will provide in person. In person only available for LTL shipments.\\n\",\n \"enum\": [\n \"details\",\n \"in-person\"\n ]\n },\n \"broker\": {\n \"type\": \"object\",\n \"description\": \"Information on the customs invoice broker.\",\n \"properties\": {\n \"use_carrier\": {\n \"type\": \"boolean\",\n \"description\": \"If true, the carrier will be used as the broker. Can only be true for courier shipments.\\n\\n**(UPDATED in 2.6.0)** For package and courier pak shipments from Canada to the US, if the customs products are valued at $800 USD or less, then use_carrier must be true.\\n\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Name of the party acting as the broker. Required if use_carrier is false.\"\n },\n \"account_number\": {\n \"type\": \"string\",\n \"description\": \"The customer's account number with the broker\"\n },\n \"phone_number\": {\n \"$ref\": \"#/components/schemas/PhoneNumber\"\n },\n \"fax_number\": {\n \"$ref\": \"#/components/schemas/PhoneNumber\"\n },\n \"email_address\": {\n \"type\": \"string\"\n },\n \"usmca_number\": {\n \"type\": \"string\"\n },\n \"fda_number\": {\n \"type\": \"string\"\n }\n }\n },\n \"details\": {\n \"type\": \"object\",\n \"description\": \"Customs invoice details.\",\n \"required\": [\n \"tax_recipient\",\n \"products\"\n ],\n \"properties\": {\n \"tax_recipient\": {\n \"type\": \"object\",\n \"required\": [\n \"type\",\n \"name\",\n \"address\",\n \"phone_number\",\n \"reason_for_export\"\n ],\n \"properties\": {\n \"type\": {\n \"type\": \"string\",\n \"description\": \"Who will pay the customs charges.\\n\\n**(UPDATED in 2.6.0)** For package and courier pak shipments from Canada to the US:\\n- If the tax-recipient type is 'shipper', then customs_data must be provided in the ShippingDetails.\\n- If the tax-recipient type is 'receiver', then customs_data must be omitted from the ShippingDetails.\\n\",\n \"enum\": [\n \"shipper\",\n \"receiver\",\n \"other\"\n ]\n },\n \"shipper_tax_identifier\": {\n \"type\": \"string\"\n },\n \"receiver_tax_identifier\": {\n \"type\": \"string\"\n },\n \"third_party_tax_identifier\": {\n \"type\": \"string\"\n },\n \"other_tax_identifier\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"address\": {\n \"$ref\": \"#/components/schemas/Address\"\n },\n \"phone_number\": {\n \"$ref\": \"#/components/schemas/PhoneNumber\"\n },\n \"reason_for_export\": {\n \"type\": \"string\",\n \"enum\": [\n \"gift\",\n \"repair-warranty\",\n \"commercial-sample\",\n \"return-shipment\",\n \"commercially-sold-goods\",\n \"other\"\n ]\n },\n \"additional_remarks\": {\n \"type\": \"string\"\n },\n \"comments\": {\n \"type\": \"string\",\n \"description\": \"Comments that will appear on the generated customs invoice document.\"\n }\n }\n },\n \"products\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"product_name\",\n \"weight\",\n \"country_of_origin\",\n \"num_units\",\n \"unit_price\",\n \"description\"\n ],\n \"properties\": {\n \"product_name\": {\n \"type\": \"string\"\n },\n \"product_id\": {\n \"type\": \"string\",\n \"description\": \"**(UPDATED in 2.9.0 and 2.10.0)** Required for EU and US Destined Shipments\"\n },\n \"product_id_type\": {\n \"type\": \"enum\",\n \"description\": \"**(UPDATED in 2.9.0 and 2.10.0)** Required for EU and US Destined Shipments\",\n \"enum\": [\n \"SKU\",\n \"MODEL_NUMBER\",\n \"SERIAL_NUMBER\",\n \"ALTERNATE_ID\",\n \"UPC\",\n \"GTIN\"\n ]\n },\n \"merchant_product_identifier\": {\n \"type\": \"string\",\n \"description\": \"**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.\"\n },\n \"non_standardised_manufacturer_product_identifier\": {\n \"type\": \"string\",\n \"description\": \"**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.\"\n },\n \"standardised_manufacturer_product_identifier\": {\n \"type\": \"string\",\n \"description\": \"**(UPDATED in 2.9.0)** Related to EU Destined Shipments only.\"\n },\n \"cpsc_regulated\": {\n \"type\": \"boolean\",\n \"description\": \"**(UPDATED in 2.10.0)** If product is CPSC Regulated, we need to toggle this to true, only applicable to US Destined Shipments.\"\n },\n \"cpsc_registered_product_information\": {\n \"$ref\": \"#/components/schemas/CPSCRegisteredProductInformation\"\n },\n \"cpsc_non_registered_product_information\": {\n \"$ref\": \"#/components/schemas/CPSCNonRegisteredProductInformation\"\n },\n \"cpsc_certificate_not_required_information\": {\n \"$ref\": \"#/components/schemas/CPSCCertificateNotRequiredInformation\"\n },\n \"weight\": {\n \"$ref\": \"#/components/schemas/Weight\"\n },\n \"hs_code\": {\n \"type\": \"string\",\n \"description\": \"**(UPDATED in 2.6.0)** HS/HTS Code. Shipments entering the US require a 10 digit HTS Code. Shipments entering the EU require an HS Code.\"\n },\n \"hsverified\": {\n \"type\": \"boolean\",\n \"description\": \"**(NEW in 2.8.0)**\\nDefaults to false. if true, `hs_code` must be picked up from the recommended ones provided by `hts-validate` api`.\\n\"\n },\n \"provided_hscode\": {\n \"type\": \"string\",\n \"description\": \"**(NEW in 2.8.0)**\\nMust be a non-zero string if `hsverified` is true. This is the provided hscode (used to get the recommended one).\\n\"\n },\n \"provided_description\": {\n \"type\": \"string\",\n \"description\": \"**(NEW in 2.8.0)**\\nMust be a non-zero string if `hsverified` is true. This is the provided description (used to get the recommended one).\\n\"\n },\n \"country_of_origin\": {\n \"type\": \"string\",\n \"description\": \"ISO 3166-1 alpha-2 code for the country.\",\n \"example\": \"CA\"\n },\n \"num_units\": {\n \"type\": \"integer\",\n \"example\": 1\n },\n \"unit_price\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"The description of the product. Maximum length of 35 characters for UPS\"\n },\n \"cusma_included\": {\n \"type\": \"boolean\",\n \"description\": \"**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US.\\n\\nIf true, you certify the goods meet CUSMA (USMCA) rules of origin and that a valid certification of origin is provided. If the carrier accepts paperless_customs_documents, a valid CUSMA document with type 'cusma-form' must be included in the paperless_customs_documents.\\n\"\n },\n \"non_auto_parts\": {\n \"type\": \"boolean\",\n \"description\": \"**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\\n\\nIf the product's HTS Code implies it may contain auto parts, then you may receive additional tariffs.\\n\\nBy specifying true in this field, you certify that your product does **not** contain auto parts.\\nThis will avoid any tariffs related to auto parts.\\n\\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to auto parts.\\n\"\n },\n \"fda_regulated\": {\n \"type\": \"enum\",\n \"description\": \"**(NEW in 2.6.2)** Applies only to package and courier pak shipments from Canada to the US.\\nRequired for these shipments.\\n\\nPlease specify \\\"yes\\\" if this product is regulated by the U.S. Food and Drug Administration (FDA) and \\\"no\\\" if it is not.\\n\\nIf your shipment contains an FDA regulated product, some carriers will not accept it.\\nBy specifying \\\"yes\\\", we can provide rates and book shipments only for carriers that will accept FDA regulated products.\\n\",\n \"enum\": [\n \"yes\",\n \"no\"\n ]\n },\n \"product_composition_allocation\": {\n \"type\": \"object\",\n \"description\": \"**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\\n\\nIf your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\\nIf you do not provide these values, you may receive higher customs charges than necessary.\\n\\n`provided` must be set to true when you provide these values.\\n\\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\\n\\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\\\"product-composition-allocation-document\\\"` must be included in the `paperless_customs_documents`.\\n\",\n \"properties\": {\n \"provided\": {\n \"type\": \"boolean\",\n \"description\": \"Defaults to false. Set to true to specify steel/aluminum/copper allocation percentages.\\n\\nDoes not affect rates if you have set `product_composition_allocation_zero` to true.\\n\\nIf both this field and `product_composition_allocation_zero` are omitted or false, then you are not specifying any steel/aluminum/copper allocation percentages, regardless of the percentage values in this object.\\nAs a result, you may receive higher customs charges than necessary.\\n\"\n },\n \"steel_percentage\": {\n \"type\": \"number\",\n \"description\": \"If your product contains steel, specify the percentage of steel that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\\n\\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\\n\",\n \"minimum\": 0,\n \"maximum\": 1\n },\n \"aluminum_percentage\": {\n \"type\": \"number\",\n \"description\": \"If your product contains aluminum, specify the percentage of aluminum that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\\n\\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\\n\",\n \"minimum\": 0,\n \"maximum\": 1\n },\n \"copper_percentage\": {\n \"type\": \"number\",\n \"description\": \"If your product contains copper, specify the percentage of copper that applies, where 0.5 means 50%. Defaults to 0 if omitted and if `provided` is true.\\n\\nMust be omitted or 0 if `provided` is false or if `product_composition_allocation_zero` is true.\\n\",\n \"minimum\": 0,\n \"maximum\": 1\n }\n }\n },\n \"product_composition_allocation_zero\": {\n \"type\": \"boolean\",\n \"description\": \"**(NEW in 2.6.1)** Applies only to package and courier pak shipments from Canada to the US.\\n\\nOptional field that defaults to false. If true, you certify that your product's composition allocation percentages are all 0%.\\n\\nFor simplicity, you may choose to ignore this field and always explicitly specify your product's composition allocation percentages, as long as you specify `product_composition_allocation.provided` true.\\n\\nIf this field is true, the `product_composition_allocation` object will not affect rates. However, if you specify a non-zero allocation percentage, you will receive an error.\\n\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"pickup_details\": {\n \"$ref\": \"#/components/schemas/PickupDetails\"\n },\n \"dispatch_details\": {\n \"$ref\": \"#/components/schemas/DispatchDetails\"\n },\n \"paperless_customs_documents\": {\n \"type\": \"array\",\n \"description\": \"**(NEW in 2.6.0)** Paperless customs documents to upload to the carrier, if supported.\\n\\nCurrently, we support paperless customs documents for international shipments with paperless rates from FedEx Courier and UPS. Each carrier limits the number of files that can be uploaded:\\n\\n- FedEx Courier: up to 5 files may be uploaded.\\n- UPS: up to 13 files may be uploaded.\\n\\nA paperless customs invoice is created automatically: it is not necessary to upload one. The paperless customs invoice does not count towards the maximum # of files that may be uploaded.\\n\\nSince an API request is limited to at most 6 MB, and files must be Base64 encoded, this puts an upper limit of approximately 4.5 MB (before Base64 encoding) on the total size of all files that may be uploaded in a single request.\\n\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"type\",\n \"file_name\",\n \"file_base64\"\n ],\n \"properties\": {\n \"type\": {\n \"type\": \"string\",\n \"description\": \"The document's type. Allowed types depend on the carrier.\\n\\nIf you have specified cusma_included true on one or more of your customs products, then you must upload a document with type 'cusma-form'.\\nIf you have specified a non-zero steel/aluminum/copper allocation on one or more of your customs products, then you must upload a document with type 'product-composition-allocation-document'.\\n\\n**Valid document types for FedEx Courier shipments**\\n\\n| type | Description |\\n| --------------------------------------- | ----------------------------------- |\\n| certificate-of-origin | Certificate of Origin |\\n| cusma-form | CUSMA Certificate |\\n| customs-invoice | Customs Invoice |\\n| fda-prior-notice | FDA Prior Notice |\\n| lacey-act-form | Lacey Act Declaration |\\n| packing-slip | Packing Slip |\\n| pro-forma-invoice | Pro Forma Invoice |\\n| product-composition-allocation-document | Steel/Aluminum/Copper Documentation |\\n| tsca | TSCA Declaration |\\n| other | Other Documents |\\n\\n**Valid document types for UPS shipments**\\n\\n| type | Description |\\n| --------------------------------------- | ----------------------------------- |\\n| authorization-form | Authorization Form |\\n| certificate-of-origin | Certificate of Origin |\\n| cusma-form | CUSMA Certificate |\\n| customs-invoice | Customs Invoice |\\n| declaration | Declaration |\\n| export-accompanying-document | Export Accompanying Document |\\n| export-license | Export License |\\n| fda-prior-notice | FDA Prior Notice |\\n| import-permit | Import Permit |\\n| lacey-act-form | Lacey Act Declaration |\\n| one-time-nafta | One Time NAFTA |\\n| packing-slip | Packing Slip |\\n| power-of-attorney | Power Of Attorney |\\n| product-composition-allocation-document | Steel/Aluminum/Copper Documentation |\\n| sed-document | SED Document |\\n| shippers-letter-of-instruction | Shipper's Letter Of Instruction |\\n| tsca | TSCA Declaration |\\n| other | Other Documents |\\n\",\n \"enum\": [\n \"cusma-form\",\n \"product-composition-allocation-document\",\n \"authorization-form\",\n \"certificate-of-origin\",\n \"customs-invoice\",\n \"declaration\",\n \"export-accompanying-document\",\n \"export-license\",\n \"fda-prior-notice\",\n \"import-permit\",\n \"lacey-act-form\",\n \"one-time-nafta\",\n \"packing-slip\",\n \"power-of-attorney\",\n \"pro-forma-invoice\",\n \"sed-document\",\n \"shippers-letter-of-instruction\",\n \"tsca\",\n \"other\"\n ]\n },\n \"type_other_name\": {\n \"type\": \"string\",\n \"description\": \"If the document's type is 'other', then this field is the document's name and is required. If the document's type is not 'other', then this field must be left empty.\"\n },\n \"file_name\": {\n \"type\": \"string\",\n \"description\": \"The document's file name, including its extension. A carrier may allow specific file extensions only, and the file's contents should match its extension.\"\n },\n \"file_base64\": {\n \"type\": \"string\",\n \"description\": \"The document file, encoded as Base64. The maximum total size of all files in a request is approximately 4.5 MB (before Base64 encoding).\"\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 202 · Success result with the shipment ID.</summary><p class=\"field-description\">Success result with the shipment ID.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Shipment ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>previously_created</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">true if the shipment was previously created with a matching unique_id.</p></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"202\": {\n \"description\": \"Success result with the shipment ID.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Shipment ID.\"\n },\n \"previously_created\": {\n \"type\": \"boolean\",\n \"description\": \"true if the shipment was previously created with a matching unique_id.\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-shipment/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Booking & labels","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/shipment</div>","section_slug":"post-shipment","section_title":"Book a shipment","summary":"API reference · Booking & labels"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Retrieve shipment & labels</h2><div class=\"field-description\">Retrieve details on a shipment.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 202 means booking is still processing and does not declare a JSON response body. Continue bounded polling. HTTP 200 contains shipment. HTTP 400 uses the shared BadData response. Inspect shipment.state and returned labels before dispatch. Preserve shipment.id, transaction_number and document URLs privately. A missing tracking event or invoice does not mean booking failed.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Book → labels → tracking</a><a href=\"#first-shipment\" data-topic=\"first-shipment\">Your first shipment</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to retrieve details on.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment ID to retrieve details on.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Details on the shipment.</summary><p class=\"field-description\">Details on the shipment.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>shipment</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Shipment ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unique_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unique ID associated with the shipment.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>state</code><span class=\"field-type\">string</span></div><p class=\"field-description\">State that the shipment is in.</p><p class=\"field-type\">Values: <code>draft</code>, <code>waiting-for-transit</code>, <code>in-transit</code>, <code>delivered</code>, <code>exception</code>, <code>missing</code>, <code>cancelled</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>transaction_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Transaction number from shipment</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>primary_tracking_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Primary tracking number for the shipment</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>tracking_numbers</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Tracking numbers for shipment</p><div class=\"field-children\"><p class=\"field-description\">Tracking numbers for shipment</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>tracking_url</code><span class=\"field-type\">string</span></div><p class=\"field-description\">External tracking URL for shipment</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>return_tracking_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Return tracking number for shipment if available</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>bol_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">BOL number for shipment</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>pickup_confirmation_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Pickup confirmation number for shipment</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>details</code><span class=\"field-type\">ShippingDetails</span></div></summary><p class=\"field-description\">Details on a shipment.</p><div class=\"field-children\"><p class=\"field-description\">Details on a shipment.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>origin</code><span class=\"field-type\">Origin</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>destination</code><span class=\"field-type\">Destination</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Combined structure</h3><details class=\"field-item\"><summary>Structure 1 · Establishment</summary><div class=\"field-children\"><p class=\"field-description\">Contains information about an individual, company, or other entity at a location.</p><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the individual or company represented by this establishment.</p><p class=\"field-type\">example: <code>Philip J Fry</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">Address</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Street address.</p><p class=\"field-type\">example: <code>200 University Avenue West</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Additional street address.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Unit/Suite/Apt.</p><p class=\"field-type\">example: <code>42a</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Name of the city.</p><p class=\"field-type\">example: <code>Waterloo</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Province or state postal abbreviation.</p><p class=\"field-type\">example: <code>ON</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Postal code or zip code</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>residential</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Whether this address is a residential.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>tailgate_required</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>instructions</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>email_addresses</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><div class=\"field-children\"><p class=\"field-description\">List of email addresses that can be used for notifications if supported by the carrier. If provided and the carrier supports receiving email addresses then one or more email addresses will be sent to the carrier. Email addresses will be sent to the carrier in the order provided in this field. Carrier may or may not provide email notifications.\n\n**(UPDATED in 2.6.1)** At least one email address is required for all international shipments.\nThis applies to both the origin and the destination.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receives_email_updates</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then the email addresses in email_addresses will be used for notifications.</p></div></div></details><details class=\"field-item\"><summary>Structure 2</summary><div class=\"field-children\"><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>signature_requirement</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">Whether a signature is required for delivery.</p><p class=\"field-type\">Values: <code>not-required</code>, <code>required</code>, <code>adult-required</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>expected_ship_date</code><span class=\"field-type\">Date</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_type</code><span class=\"field-type\">PackagingType</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>pallet</code>, <code>package</code>, <code>courier-pak</code>, <code>envelope</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packaging_properties</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><h3>Choose one structure</h3><details class=\"field-item\"><summary>Structure 1 · PackagingPallet</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>pallet_type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The pallet types.</p><p class=\"field-type\">Values: <code>ltl</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_stackable_pallets</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Pallets are stackable.</p><p class=\"field-type\">example: <code>true</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>dangerous_goods</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The shipment's dangerous goods. Empty if it does not contain dangerous goods.</p><p class=\"field-type\">Values: <code>limited-quantity</code>, <code>exemption-500-kg</code>, <code>fully-regulated</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">DangerousGoodsDetails</span></div></summary><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-children\"><p class=\"field-description\">pallet dangerous goods details that are utilized on the BOL. Required if there are dangerous goods when creating a shipment. All fields are required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>packaging_group</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>emergency_contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>emergency_contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallets</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of values</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pallet_service_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-children\"><p class=\"field-description\">Details on the delivery of pallets.</p><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">If limited access delivery the type of delivery.</p><p class=\"field-type\">Values: <code>construction-site</code>, <code>fair</code>, <code>farm</code>, <code>mall</code>, <code>mini-storage-unit</code>, <code>place-of-worship</code>, <code>school</code>, <code>secured-location</code>, <code>other</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>limited_access_delivery_other_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Provided if the limited_access_type is 'other'.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>in_bond</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If the shipment requires a US in-bond service.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>in_bond_details</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Details for in bond if needed.</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>appointment_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>protect_from_freeze</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_pickup</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>threshold_delivery</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\"></p></div></div></details></div></details><details class=\"field-item\"><summary>Structure 2 · PackagingPackage</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Indicates the shipment's packages contain dangerous goods. When true, dangerous_goods_details must also be provided.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dangerous_goods_details</code><span class=\"field-type\">PackageDangerousGoodsDetails</span></div></summary><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-children\"><p class=\"field-description\">Dangerous goods details for package shipments. Required when has_dangerous_goods is true.</p><div class=\"field-item\"><div class=\"field-heading\"><code>goods_class</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>united_nations_number</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>packages</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></div></details></div></details><details class=\"field-item\"><summary>Structure 3 · PackagingCourierPak</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>has_dangerous_goods</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Courier paks contain dangerous goods.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>courier_paks</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></div></details></div></details><details class=\"field-item\"><summary>Structure 4 · PackagingEnvelope</summary><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>includes_return_label</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then return labels will be included in the shipment documents.</p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>insurance</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-children\"><p class=\"field-description\">Insurance details for a shipment, if required.</p><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>internal</code>, <code>carrier</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>total_cost</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>reference_codes</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Reference codes for the shipment.</p><div class=\"field-children\"><p class=\"field-description\">Reference codes for the shipment.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_classification</code><span class=\"field-type\">ShipmentClassification</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>B2B</code>, <code>B2C</code>, <code>C2B</code>, <code>C2C</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** Applies only to package and courier pak shipments from Canada to the US. If present, the rates will include customs charges and the shipment will be booked with DDP (shipper pays the customs charges). The customs charges will be based on the data in this object.\nIf customs_invoice.details is also present, its tax_recipient.type must be 'shipper' and its products must contain the same data as this object's products.\n</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>products</code><span class=\"field-type\">array</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><div class=\"field-children\"><p class=\"field-description\">Data for customs about the products being shipped. If customs_invoice.details is also present, it must contain the same products as this array.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>hs_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The 10 digit HTS Code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>hsverified</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nDefaults to false. if true, `hs_code` must be picked up from the recommended ones provided by `hts-validate` api`.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the name of the customs product which you are shipping.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_hscode</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided hscode (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(NEW in 2.8.0)**\nMust be a non-zero string if `hsverified` is true. This is the provided description (used to get the recommended one).\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country_of_origin</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 code for the country.</p><p class=\"field-type\">example: <code>CA</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>product_id_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">**(UPDATED in 2.9.0 and 2.10.0)** Required for US Destined Shipments</p><p class=\"field-type\">Values: <code>SKU</code>, <code>MODEL_NUMBER</code>, <code>SERIAL_NUMBER</code>, <code>ALTERNATE_ID</code>, <code>UPC</code>, <code>GTIN</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cpsc_regulated</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(UPDATED in 2.10.0)** If product is CPSC Regulated, we need to toggle this to true, only applicable to US Destined Shipments.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_registered_product_information</code><span class=\"field-type\">CPSCRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for registered products on CPSC Registry (if not must be null).</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_non_registered_product_information</code><span class=\"field-type\">CPSCNonRegisteredProductInformation</span></div></summary><p class=\"field-description\">Information required for non-registered CPSC regulated products (if not must be null).</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_certificate_not_required_information</code><span class=\"field-type\">CPSCCertificateNotRequiredInformation</span></div></summary><p class=\"field-description\">Information when CPSC certificate is not required (if not must be null).</p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>num_units</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>1</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>unit_price</code><span class=\"field-type\">Money</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p>Refer to the official API documentation for the complete model definition.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The description of the product. Maximum length of 35 characters for UPS</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>cusma_included</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Defaults to false. If true, you certify the goods meet CUSMA (USMCA) rules of origin and that a valid certification of origin is provided.\n\nIf the carrier accepts paperless_customs_documents, a valid CUSMA document with type 'cusma-form' must be included in the paperless_customs_documents.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>non_auto_parts</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain auto parts, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does **not** contain auto parts.\nThis will avoid any tariffs related to auto parts.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to auto parts.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>completed_kitchen_cabinets_or_vanities</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If the product's HTS Code implies it may contain completed kitchen cabinets or vanities, then you may receive additional tariffs.\n\nBy specifying true in this field, you certify that your product does contain completed kitchen cabinets or vanities.\nThis will avoid any tariffs related to not completed kitchen cabinets or vanities.\n\nIf this field is false or omitted, the product's HTS Code will determine whether you receive any tariffs related to completed kitchen cabinets or vanities.\n</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>fda_regulated</code><span class=\"field-type\">enum</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">**(NEW in 2.6.2)** Please specify \"yes\" if this product is regulated by the U.S. Food and Drug Administration (FDA) and \"no\" if it is not.\n\nIf your shipment contains an FDA regulated product, some carriers will not accept it.\nBy specifying \"yes\", we can provide rates and book shipments only for carriers that will accept FDA regulated products.\n</p><p class=\"field-type\">Values: <code>yes</code>, <code>no</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>product_composition_allocation</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** If your product contains steel/aluminum/copper, provide this object with the applicable allocation percentages.\nIf you do not provide these values, you may receive higher customs charges than necessary.\n\n`provided` must be set to true when you provide these values.\n\nTo specify zero steel/aluminum/copper allocation, you must either set `provided` to true, or set `product_composition_allocation_zero` to true in the parent object.\nIf `product_composition_allocation_zero` is true, this object will not affect rates and can be omitted.\n\nIf you specify a non-zero allocation and the carrier accepts `paperless_customs_documents`, a valid Steel/Aluminum/Copper document with type `\"product-composition-allocation-document\"` must be included in the `paperless_customs_documents`.\n</p><div class=\"field-children\"><p>Inspect the complete definition below.</p></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>product_composition_allocation_zero</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** Optional field that defaults to false. If true, you certify that your product's composition allocation percentages are all 0%.\n\nFor simplicity, you may choose to ignore this field and always explicitly specify your product's composition allocation percentages, as long as you specify `product_composition_allocation.provided` true.\n\nIf this field is true, the `product_composition_allocation` object will not affect rates. However, if you specify a non-zero allocation percentage, you will receive an error.\n</p></div></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>request_guaranteed_customs_charges</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If false or omitted, customs charges will be estimates only. If true, guaranteed customs charges will be requested.\nIf a rate has is_rate_guaranteed true, then all of its customs charges are guaranteed - provided the product information, description and HTS codes are correct.\n</p></div></div></details></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>transport_data</code><span class=\"field-type\">object</span></div><p class=\"field-description\">Additional transport data for the shipment</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>labels</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Labels for the shipment</p><div class=\"field-children\"><p class=\"field-description\">Labels for the shipment</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>size</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>letter</code>, <code>a6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>format</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>pdf</code>, <code>zpl</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>url</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>padded</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If padded is true there can be padding added to offset the label to avoid being cut off when printing.</p></div></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>customs_invoice_url</code><span class=\"field-type\">string</span></div><p class=\"field-description\">URL of customs invoice if uploaded or generated.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>rate</code><span class=\"field-type\">Rate</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>carrier_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the carrier.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The name of the service.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The ID of the service, utilized for booking.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>valid_until</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>total</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>base</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>surcharges</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">An array of surcharges.</p><div class=\"field-children\"><p class=\"field-description\">An array of surcharges.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The surcharge type.</p><p class=\"field-type\">example: <code>fuel</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>taxes</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">An array of taxes.</p><div class=\"field-children\"><p class=\"field-description\">An array of taxes.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The tax type.</p><p class=\"field-type\">example: <code>fuel</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>transit_time_days</code><span class=\"field-type\">integer</span></div><p class=\"field-description\">The number of days that the shipment will take to reach the destination.</p><p class=\"field-type\">example: <code>5</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>transit_time_not_available</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Some carriers may not provide a valid transit time. If this value is true then transit_time_days should be ignored regardless of the value provided.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>paperless</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.0)** If true then the rate supports a paperless customs invoice. With certain carriers, you may upload additional paperless customs documents when booking the shipment, such as a CUSMA Certificate, by providing paperless_customs_documents when booking.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>customs_charge_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** If present, contains data about the customs charges for a DDP shipment (shipper pays the customs charges).</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** If present, contains data about the customs charges for a DDP shipment (shipper pays the customs charges).</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>duties_and_taxes_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The surcharge types that correspond to customs duties and taxes charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional duties and taxes charges - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">The surcharge types that correspond to customs duties and taxes charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional duties and taxes charges - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>guarantee_fee_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** When is_rate_guaranteed is true, these surcharge types correspond to the additional fees to guarantee all customs charges.\nShould be empty when is_rate_guaranteed is false.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** When is_rate_guaranteed is true, these surcharge types correspond to the additional fees to guarantee all customs charges.\nShould be empty when is_rate_guaranteed is false.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>carrier_and_government_fees_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.1)** The surcharge types that correspond to customs carrier and government fees.\nThis includes everything related to the customs clearance of your shipment such as clearance, brokerage, FDA, disbursement, MPF, line item, PGA etc.\n\nIf is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional charges on the clearance of this shipment - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.1)** The surcharge types that correspond to customs carrier and government fees.\nThis includes everything related to the customs clearance of your shipment such as clearance, brokerage, FDA, disbursement, MPF, line item, PGA etc.\n\nIf is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional charges on the clearance of this shipment - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>processing_fees_surcharge_keys</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The surcharge types that correspond to customs processing fees charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional processing fees - provided the product information, description and HTS codes are correct.\n</p><div class=\"field-children\"><p class=\"field-description\">The surcharge types that correspond to customs processing fees charges.\n\n**(UPDATED in 2.6.1)** When is_rate_guaranteed is true, these charges are guaranteed: you will not receive any additional processing fees - provided the product information, description and HTS codes are correct.\n</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>is_rate_guaranteed</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">**(NEW in 2.6.1)** If true, then all customs charges are guaranteed: you will not receive any additional customs charges - provided the product information, description and HTS codes are correct.\nThis encompasses all surcharge types belonging to the customs_charge_data fields.\n\nTo receive guaranteed customs charges, you must specify customs_data.request_guaranteed_customs_charges true when requesting a rate or booking a shipment.\n</p></div></div></details></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>order_source</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Order source for shipment</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>paperless_customs_documents</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">**(NEW in 2.6.0)** Paperless customs documents that were successfully uploaded to the carrier.</p><div class=\"field-children\"><p class=\"field-description\">**(NEW in 2.6.0)** Paperless customs documents that were successfully uploaded to the carrier.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The document's ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The document's type.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type_other_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">If the document's type is 'other', then this is the document's name.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>file_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The document's file name, including its extension.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>url</code><span class=\"field-type\">string</span></div><p class=\"field-description\">A URL to download the file. Valid for only 1 hour.</p></div></div></div></details></div></details></details><details class=\"response-status\" open=\"\"><summary>HTTP 202 · Shipment is currently in the process of being booked. Please try again shortly.</summary><p class=\"field-description\">Shipment is currently in the process of being booked. Please try again shortly.</p></details><details class=\"response-status\"><summary>HTTP 400 · Request data is incorrect or conflicts with existing customer information.</summary><p class=\"field-description\">Request data is incorrect or conflicts with existing customer information.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>message</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The error message.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>data</code><span class=\"field-type\">object</span></div><p class=\"field-description\">Additional data about the error.</p></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Details on the shipment.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"shipment\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Shipment ID.\"\n },\n \"unique_id\": {\n \"type\": \"string\",\n \"description\": \"Unique ID associated with the shipment.\"\n },\n \"state\": {\n \"type\": \"string\",\n \"description\": \"State that the shipment is in.\",\n \"enum\": [\n \"draft\",\n \"waiting-for-transit\",\n \"in-transit\",\n \"delivered\",\n \"exception\",\n \"missing\",\n \"cancelled\"\n ]\n },\n \"transaction_number\": {\n \"type\": \"string\",\n \"description\": \"Transaction number from shipment\"\n },\n \"primary_tracking_number\": {\n \"type\": \"string\",\n \"description\": \"Primary tracking number for the shipment\"\n },\n \"tracking_numbers\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"Tracking numbers for shipment\"\n },\n \"tracking_url\": {\n \"type\": \"string\",\n \"description\": \"External tracking URL for shipment\"\n },\n \"return_tracking_number\": {\n \"type\": \"string\",\n \"description\": \"Return tracking number for shipment if available\"\n },\n \"bol_number\": {\n \"type\": \"string\",\n \"description\": \"BOL number for shipment\"\n },\n \"pickup_confirmation_number\": {\n \"type\": \"string\",\n \"description\": \"Pickup confirmation number for shipment\"\n },\n \"details\": {\n \"$ref\": \"#/components/schemas/ShippingDetails\"\n },\n \"transport_data\": {\n \"type\": \"object\",\n \"description\": \"Additional transport data for the shipment\"\n },\n \"labels\": {\n \"type\": \"array\",\n \"description\": \"Labels for the shipment\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"size\": {\n \"type\": \"string\",\n \"enum\": [\n \"letter\",\n \"a6\"\n ]\n },\n \"format\": {\n \"type\": \"string\",\n \"enum\": [\n \"pdf\",\n \"zpl\"\n ]\n },\n \"url\": {\n \"type\": \"string\"\n },\n \"padded\": {\n \"type\": \"boolean\",\n \"description\": \"If padded is true there can be padding added to offset the label to avoid being cut off when printing.\"\n }\n }\n }\n },\n \"customs_invoice_url\": {\n \"type\": \"string\",\n \"description\": \"URL of customs invoice if uploaded or generated.\"\n },\n \"rate\": {\n \"$ref\": \"#/components/schemas/Rate\"\n },\n \"order_source\": {\n \"type\": \"string\",\n \"description\": \"Order source for shipment\"\n },\n \"paperless_customs_documents\": {\n \"type\": \"array\",\n \"description\": \"**(NEW in 2.6.0)** Paperless customs documents that were successfully uploaded to the carrier.\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"The document's ID.\"\n },\n \"type\": {\n \"type\": \"string\",\n \"description\": \"The document's type.\"\n },\n \"type_other_name\": {\n \"type\": \"string\",\n \"description\": \"If the document's type is 'other', then this is the document's name.\"\n },\n \"file_name\": {\n \"type\": \"string\",\n \"description\": \"The document's file name, including its extension.\"\n },\n \"url\": {\n \"type\": \"string\",\n \"description\": \"A URL to download the file. Valid for only 1 hour.\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n },\n \"202\": {\n \"description\": \"Shipment is currently in the process of being booked. Please try again shortly.\"\n },\n \"400\": {\n \"$ref\": \"#/components/responses/BadData\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-shipment-shipment-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Booking & labels","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/shipment/{shipment_id}</div>","section_slug":"get-shipment-shipment-id","section_title":"Retrieve shipment & labels","summary":"API reference · Booking & labels"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"DELETE\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'DELETE';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'DELETE';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'DELETE'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'DELETE';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"DELETE\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"DELETE\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"DELETE\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'DELETE'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'DELETE'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"DELETE\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"DELETE\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"DELETE\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Cancel a shipment</h2><div class=\"field-description\">Cancel a shipment. Will also remove any unique_id association with the shipment.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>This cancels the shipment and removes its unique_id association. HTTP 200 does not declare a response body. Reusing the old unique_id after cancellation permits a new booking. Confirm the shipment and account before running this request.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#booking-workflow\" data-topic=\"booking-workflow\">Book → labels → tracking</a><a href=\"#first-shipment\" data-topic=\"first-shipment\">Your first shipment</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to cancel.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment ID to cancel.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Shipment cancelled.</summary><p class=\"field-description\">Shipment cancelled.</p></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Shipment cancelled.\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/delete-shipment-shipment-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Booking & labels","rich_content":"<div class=\"endpoint-pill\"><b>DELETE</b>/shipment/{shipment_id}</div>","section_slug":"delete-shipment-shipment-id","section_title":"Cancel a shipment","summary":"API reference · Booking & labels"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-tracking-events\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/tracking-events\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Retrieve tracking events</h2><div class=\"field-description\">Retrieve tracking events for a shipment.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 200 contains events. Event timestamps in when use UTC. Preserve the documented event type and message, including exception, missing and customs-hold. Poll this read endpoint on your chosen schedule. No webhook endpoint is declared in the specification.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to retrieve details on.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment ID to retrieve details on.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Shipment tracking events.</summary><p class=\"field-description\">Shipment tracking events.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>events</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>label-created</code>, <code>ready-to-dispatch</code>, <code>dispatched</code>, <code>picked-up</code>, <code>in-transit</code>, <code>out-for-delivery</code>, <code>delivered</code>, <code>customs-hold</code>, <code>customs-cleared</code>, <code>cancelled</code>, <code>exception</code>, <code>missing</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>when</code><span class=\"field-type\">string</span></div><p class=\"field-description\">in UTC</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>where</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>message</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Shipment tracking events.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"events\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"label-created\",\n \"ready-to-dispatch\",\n \"dispatched\",\n \"picked-up\",\n \"in-transit\",\n \"out-for-delivery\",\n \"delivered\",\n \"customs-hold\",\n \"customs-cleared\",\n \"cancelled\",\n \"exception\",\n \"missing\"\n ]\n },\n \"when\": {\n \"type\": \"string\",\n \"description\": \"in UTC\"\n },\n \"where\": {\n \"type\": \"object\",\n \"properties\": {\n \"city\": {\n \"type\": \"string\"\n },\n \"region\": {\n \"type\": \"string\"\n },\n \"country\": {\n \"type\": \"string\"\n }\n }\n },\n \"message\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-shipment-shipment-id-tracking-events/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Tracking","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/shipment/{shipment_id}/tracking-events</div>","section_slug":"get-shipment-shipment-id-tracking-events","section_title":"Retrieve tracking events","summary":"API reference · Tracking"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Check pickup schedule</h2><div class=\"field-description\">Get details on scheduling.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 200 is not sufficient to establish pickup success. Check status: pending, timed-out, error or done. Continue bounded reads only for pending. Surface error and stop on timed-out or error. Save pickup_confirmation_number when provided. HTTP 400 means scheduling information was not found. HTTP 404 means the shipment was not found.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to get the scheduling status.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment ID to get the scheduling status.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Current scheduling status.</summary><p class=\"field-description\">Current scheduling status.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>status</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>pending</code>, <code>timed-out</code>, <code>error</code>, <code>done</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>error</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>pickup_confirmation_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></details><details class=\"response-status\"><summary>HTTP 400 · Shipment scheduling information not found.</summary><p class=\"field-description\">Shipment scheduling information not found.</p></details><details class=\"response-status\"><summary>HTTP 404 · Shipment not found.</summary><p class=\"field-description\">Shipment not found.</p></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Current scheduling status.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\",\n \"enum\": [\n \"pending\",\n \"timed-out\",\n \"error\",\n \"done\"\n ]\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"pickup_confirmation_number\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n },\n \"400\": {\n \"description\": \"Shipment scheduling information not found.\"\n },\n \"404\": {\n \"description\": \"Shipment not found.\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-shipment-shipment-id-schedule/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Pickups","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/shipment/{shipment_id}/schedule</div>","section_slug":"get-shipment-shipment-id-schedule","section_title":"Check pickup schedule","summary":"API reference · Pickups"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"pickup_details\": {\n \"pre_scheduled_pickup\": false,\n \"date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"ready_at\": {\n \"hour\": 13,\n \"minute\": 0\n },\n \"ready_until\": {\n \"hour\": 17,\n \"minute\": 0\n },\n \"pickup_location\": \"Reception\",\n \"contact_name\": \"Shipping Team\",\n \"contact_phone_number\": {\n \"number\": \"5195550100\"\n }\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Schedule a pickup</h2><div class=\"field-description\">Schedule a dispatch or pickup.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Supply pickup_details for courier pickup or dispatch_details for pallet dispatch. HTTP 202 indicates an attempt, with no declared body. Poll GET /shipment/{shipment_id}/schedule and inspect its status until done or a terminal failure. Do not treat acceptance as a confirmed pickup.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to schedule.</p></div><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pickup_details</code><span class=\"field-type\">PickupDetails</span></div></summary><p class=\"field-description\">Courier pickup details, required if courier service utilized.</p><div class=\"field-children\"><p class=\"field-description\">Courier pickup details, required if courier service utilized.</p><div class=\"field-item\"><div class=\"field-heading\"><code>pre_scheduled_pickup</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">If true then all other fields are ignored. Indicates that the customer has their own arrangements with the carrier for scheduling.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>pickup_location</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>contact_name</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>contact_phone_number</code><span class=\"field-type\">PhoneNumber</span></div></summary><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-children\"><p class=\"field-description\">Phone number without any special characters.</p><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>5554447777</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>extension</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>123</code></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>dispatch_details</code><span class=\"field-type\">DispatchDetails</span></div></summary><p class=\"field-description\">pallet dispatch details, required if dispatch service utilized.</p><div class=\"field-children\"><p class=\"field-description\">pallet dispatch details, required if dispatch service utilized.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_at</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>ready_until</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"pickup_details\": {\n \"$ref\": \"#/components/schemas/PickupDetails\"\n },\n \"dispatch_details\": {\n \"$ref\": \"#/components/schemas/DispatchDetails\"\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 202 · Scheduling is being attempted. Check shipment details to determine if state has changed.</summary><p class=\"field-description\">Scheduling is being attempted. Check shipment details to determine if state has changed.</p></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"202\": {\n \"description\": \"Scheduling is being attempted. Check shipment details to determine if state has changed.\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-shipment-shipment-id-schedule/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Pickups","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/shipment/{shipment_id}/schedule</div>","section_slug":"post-shipment-shipment-id-schedule","section_title":"Schedule a pickup","summary":"API reference · Pickups"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"DELETE\"\nurl=\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'DELETE';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'DELETE';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'DELETE'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'DELETE';\n$ch = curl_init('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"DELETE\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"DELETE\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"DELETE\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'DELETE'\nuri = URI('https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'DELETE'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"DELETE\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"DELETE\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#delete-shipment-shipment-id-schedule\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. This request cancels a resource. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"DELETE\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/REPLACE_WITH_SHIPMENT_ID/schedule\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Cancel a pickup</h2><div class=\"field-description\">Cancel a scheduling.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Cancel scheduling for the supplied shipment ID. HTTP 200 has no declared response body. Cancelling a pickup or dispatch is separate from cancelling the shipment.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment ID to cancel scheduling for.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment ID to cancel scheduling for.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Shipment scheduling cancelled.</summary><p class=\"field-description\">Shipment scheduling cancelled.</p></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Shipment scheduling cancelled.\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/delete-shipment-shipment-id-schedule/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Pickups","rich_content":"<div class=\"endpoint-pill\"><b>DELETE</b>/shipment/{shipment_id}/schedule</div>","section_slug":"delete-shipment-shipment-id-schedule","section_title":"Cancel a pickup","summary":"API reference · Pickups"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment/schedule/validate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/schedule/validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/schedule/validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/schedule/validate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment/schedule/validate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/schedule/validate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/schedule/validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/schedule/validate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment/schedule/validate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/schedule/validate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/schedule/validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/schedule/validate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-schedule-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/schedule/validate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"service_id\": \"REPLACE_WITH_SERVICE_ID\",\n \"origin\": {\n \"package_type\": \"package\",\n \"postal_code\": \"N2L 3G1\",\n \"country\": \"CA\"\n },\n \"destination\": {\n \"postal_code\": \"M5H 2N2\",\n \"country\": \"CA\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Get courier pickup availability</h2><div class=\"field-description\">If date/ready_at/ready_until are omitted, defaults are used.\nThe response returns the validated pickup window. If the requested window is not available,\nthe window may be adjusted to the next available window. When a full window is provided, exact_match\nindicates whether the returned window matches the requested window. Supported packaging types: package,\ncourier-pak, envelope.\n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Courier pickup availability only, for package, courier-pak or envelope. Supply carrier_id, service_id, origin and destination. The request schema names the optional window fields pickup_date, open_time and close_time. The returned window might differ from the requested one. The prose mentions date/ready_at/ready_until and exact_match, but these are not the declared request fields or response property. Confirm this inconsistency with Freightcom. Do not depend on exact_match without confirmation. GET /services does not declare carrier_id, so obtain the correct carrier identifier through your Freightcom integration contact.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><div class=\"field-item\"><div class=\"field-heading\"><code>carrier_id</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>service_id</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>origin</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>package_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 country code.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>address</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_1</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>address_line_2</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>region</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>city</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>unit_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>destination</code><span class=\"field-type\">object</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>postal_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Optional for pickup availability checks.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country</code><span class=\"field-type\">string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">ISO 3166-1 alpha-2 country code.</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pickup_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>open_time</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>close_time</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"required\": [\n \"carrier_id\",\n \"service_id\",\n \"origin\",\n \"destination\"\n ],\n \"properties\": {\n \"carrier_id\": {\n \"type\": \"string\"\n },\n \"service_id\": {\n \"type\": \"string\"\n },\n \"origin\": {\n \"type\": \"object\",\n \"required\": [\n \"postal_code\",\n \"country\"\n ],\n \"properties\": {\n \"package_type\": {\n \"type\": \"string\"\n },\n \"postal_code\": {\n \"type\": \"string\"\n },\n \"country\": {\n \"type\": \"string\",\n \"description\": \"ISO 3166-1 alpha-2 country code.\"\n },\n \"address\": {\n \"type\": \"object\",\n \"properties\": {\n \"address_line_1\": {\n \"type\": \"string\"\n },\n \"address_line_2\": {\n \"type\": \"string\"\n },\n \"region\": {\n \"type\": \"string\"\n },\n \"city\": {\n \"type\": \"string\"\n },\n \"unit_number\": {\n \"type\": \"string\"\n }\n }\n }\n }\n },\n \"destination\": {\n \"type\": \"object\",\n \"required\": [\n \"country\"\n ],\n \"properties\": {\n \"postal_code\": {\n \"type\": \"string\",\n \"description\": \"Optional for pickup availability checks.\"\n },\n \"country\": {\n \"type\": \"string\",\n \"description\": \"ISO 3166-1 alpha-2 country code.\"\n }\n }\n },\n \"pickup_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"open_time\": {\n \"$ref\": \"#/components/schemas/TimeOfDay\"\n },\n \"close_time\": {\n \"$ref\": \"#/components/schemas/TimeOfDay\"\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Validated pickup window.</summary><p class=\"field-description\">Validated pickup window.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>pickup_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>open_time</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>close_time</code><span class=\"field-type\">TimeOfDay</span></div></summary><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-children\"><p class=\"field-description\">Time of day in 24 hour time.</p><div class=\"field-item\"><div class=\"field-heading\"><code>hour</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>15</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>minute</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Validated pickup window.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"pickup_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"open_time\": {\n \"$ref\": \"#/components/schemas/TimeOfDay\"\n },\n \"close_time\": {\n \"$ref\": \"#/components/schemas/TimeOfDay\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-shipment-schedule-validate/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Pickups","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/shipment/schedule/validate</div>","section_slug":"post-shipment-schedule-validate","section_title":"Validate pickup availability","summary":"API reference · Pickups"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment/hts-validate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/hts-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/hts-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/hts-validate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment/hts-validate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/hts-validate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/hts-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/hts-validate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment/hts-validate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/hts-validate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/hts-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/hts-validate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-hts-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/hts-validate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"data\": [\n {\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"Printed books\",\n \"description\": \"Bound printed books\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Get Validated HTS Codes</h2><div class=\"field-description\">Use Recommended HTS code for your customs' products.\nAll fields are optional but must be provided for the most accurate results.\n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Provide the original code, name and description for each product. The response is an array with provided_code, provided_description and recommended_array entries containing valid_code and valid_description. Choose the appropriate recommendation. For eligible Canada-to-US packages and courier paks, pass its code as hs_code with the corresponding description. If hsverified is true, include product_name, provided_hscode and provided_description. A guarantee request must still be confirmed through customs_charge_data.is_rate_guaranteed.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#customs\" data-topic=\"customs\">Cross-border & customs</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>data</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">HTS Code to validate.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product Name related to the provided HTS code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product Description related to the provided HTS code.</p></div></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"data\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"code\": {\n \"type\": \"string\",\n \"description\": \"HTS Code to validate.\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Product Name related to the provided HTS code.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Product Description related to the provided HTS code.\"\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Validated HTS Codes.</summary><p class=\"field-description\">Validated HTS Codes.</p><h3>application/json</h3><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>provided_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Provided `HTS` to validate.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>provided_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Related description to the provided `HTS` code.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>recommended_array</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>valid_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">A valid code which can be used.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>valid_description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">A valid description which must be used in correspond to its related `valid_code`.</p></div></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Validated HTS Codes.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"provided_code\": {\n \"type\": \"string\",\n \"description\": \"Provided `HTS` to validate.\"\n },\n \"provided_description\": {\n \"type\": \"string\",\n \"description\": \"Related description to the provided `HTS` code.\"\n },\n \"recommended_array\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"valid_code\": {\n \"type\": \"string\",\n \"description\": \"A valid code which can be used.\"\n },\n \"valid_description\": {\n \"type\": \"string\",\n \"description\": \"A valid description which must be used in correspond to its related `valid_code`.\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-shipment-hts-validate/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Customs","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/shipment/hts-validate</div>","section_slug":"post-shipment-hts-validate","section_title":"Validate HTS codes","summary":"API reference · Customs"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/shipment/regulations-validate\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/regulations-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/regulations-validate', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/regulations-validate', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/shipment/regulations-validate');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/regulations-validate\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/regulations-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/regulations-validate\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/shipment/regulations-validate')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/regulations-validate'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/regulations-validate\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/regulations-validate\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-shipment-regulations-validate\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/regulations-validate\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"regulation_type\": \"CPSC\",\n \"data\": [\n {\n \"id\": \"product-001\",\n \"code\": \"REPLACE_WITH_PRODUCT_HTS\",\n \"name\": \"REPLACE_WITH_PRODUCT_NAME\",\n \"description\": \"REPLACE_WITH_ACCURATE_PRODUCT_DESCRIPTION\",\n \"country_of_origin\": \"CA\"\n }\n ]\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Get Validated Regulation Information</h2><div class=\"field-description\">Validate regulations for your customs' products.\nAll fields are optional but must be provided for the most accurate results.\n`id` is used for mapping request to response and does not have any impact over the returned results. \n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Use regulation_type CPSC and accurate product code, name, description and country_of_origin. Use each input id to map the returned array entry. Inspect regulated and cpsc_regulated_data. Select the applicable registered, non-registered or certificate-not-required customs branch for US-destined products. The source describes nullable response fields without consistently declaring nullable schemas, so handle null values.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#customs\" data-topic=\"customs\">Cross-border & customs</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><div class=\"field-item\"><div class=\"field-heading\"><code>regulation_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">Regulation Type to check for, only `CPSC` is available currently.</p><p class=\"field-type\">Values: <code>CPSC</code></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>data</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Id for request and response mapping.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">HTS Code to validate.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>name</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product Name related to the provided HTS code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>description</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product Description related to the provided HTS code.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>country_of_origin</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Product Origin Country (must be a valid ISO 3166-1 country code).</p></div></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"regulation_type\": {\n \"type\": \"enum\",\n \"description\": \"Regulation Type to check for, only `CPSC` is available currently.\",\n \"enum\": [\n \"CPSC\"\n ]\n },\n \"data\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Id for request and response mapping.\"\n },\n \"code\": {\n \"type\": \"string\",\n \"description\": \"HTS Code to validate.\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Product Name related to the provided HTS code.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Product Description related to the provided HTS code.\"\n },\n \"country_of_origin\": {\n \"type\": \"string\",\n \"description\": \"Product Origin Country (must be a valid ISO 3166-1 country code).\"\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Validated Regulation Results.</summary><p class=\"field-description\">Validated Regulation Results.</p><h3>application/json</h3><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>regulated</code><span class=\"field-type\">boolean</span></div><p class=\"field-description\">Tells if the Product is Regulated with the provided `regulation_type`.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The passed `id` in request for mapping.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>cpsc_regulated_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>certificate_type</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">CPSC's Certificate Type required for this product otherwise null.</p><p class=\"field-type\">Values: <code>CPC</code>, <code>GCC</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>disclaimer_code</code><span class=\"field-type\">enum</span></div><p class=\"field-description\">CPSC's Disclaimer Type required for this product if `Certificate data` is not required otherwise null.</p><p class=\"field-type\">Values: <code>A</code>, <code>B</code></p></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Validated Regulation Results.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"regulated\": {\n \"type\": \"boolean\",\n \"description\": \"Tells if the Product is Regulated with the provided `regulation_type`.\"\n },\n \"id\": {\n \"type\": \"string\",\n \"description\": \"The passed `id` in request for mapping.\"\n },\n \"cpsc_regulated_data\": {\n \"type\": \"object\",\n \"properties\": {\n \"certificate_type\": {\n \"type\": \"enum\",\n \"description\": \"CPSC's Certificate Type required for this product otherwise null.\",\n \"enum\": [\n \"CPC\",\n \"GCC\"\n ]\n },\n \"disclaimer_code\": {\n \"type\": \"enum\",\n \"description\": \"CPSC's Disclaimer Type required for this product if `Certificate data` is not required otherwise null.\",\n \"enum\": [\n \"A\",\n \"B\"\n ]\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-shipment-regulations-validate/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Customs","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/shipment/regulations-validate</div>","section_slug":"post-shipment-regulations-validate","section_title":"Validate product regulations","summary":"API reference · Customs"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/shipment/intended-use-details\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/intended-use-details', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/intended-use-details', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/intended-use-details', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/shipment/intended-use-details');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/intended-use-details\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/intended-use-details\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/intended-use-details\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/shipment/intended-use-details')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/intended-use-details'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/intended-use-details\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/intended-use-details\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-intended-use-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/intended-use-details\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Get Intended Use Case Map</h2><div class=\"field-description\">Returns a map of product categories to a map of use case codes and descriptions.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>The response maps product categories to maps of intended-use code to description. Read the relevant category and preserve the exact returned code and description. Do not substitute the illustrative example for the current response.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#customs\" data-topic=\"customs\">Cross-border & customs</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Successful response</summary><p class=\"field-description\">Successful response</p><h3>application/json</h3><p class=\"field-description\">Map of product category to a map of use-case-code -> description.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>MedicalDevices</code><span class=\"field-type\">UseCaseCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of use case code to description.</p><p class=\"field-type\">example: <code>{\"081.001\":\"For Human Medical Use as a Medical Device\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of use case code to description.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">Description of the intended use code.</p><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>Food</code><span class=\"field-type\">UseCaseCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of use case code to description.</p><p class=\"field-type\">example: <code>{\"081.001\":\"For Human Medical Use as a Medical Device\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of use case code to description.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">Description of the intended use code.</p><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>Cosmetic</code><span class=\"field-type\">UseCaseCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of use case code to description.</p><p class=\"field-type\">example: <code>{\"081.001\":\"For Human Medical Use as a Medical Device\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of use case code to description.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">Description of the intended use code.</p><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>Biological</code><span class=\"field-type\">UseCaseCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of use case code to description.</p><p class=\"field-type\">example: <code>{\"081.001\":\"For Human Medical Use as a Medical Device\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of use case code to description.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">Description of the intended use code.</p><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>CPSC</code><span class=\"field-type\">UseCaseCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of use case code to description.</p><p class=\"field-type\">example: <code>{\"081.001\":\"For Human Medical Use as a Medical Device\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of use case code to description.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">Description of the intended use code.</p><p class=\"field-type\">Type: string</p></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Successful response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/IntendedUseCaseMap\"\n },\n \"example\": {\n \"MedicalDevices\": {\n \"081.001\": \"For Human Medical Use as a Medical Device\",\n \"081.002\": \"Import of a foreign-manufactured device for domestic refurbishing\"\n },\n \"Food\": {\n \"210.000\": \"For Personal Use as Human Food\",\n \"970.000\": \"Import for Export\"\n },\n \"Cosmetic\": {\n \"100.000\": \"Importation for Personal Use\",\n \"970.000\": \"Import for Export\"\n },\n \"Biological\": {\n \"080.000\": \"For Human Medical Use as a Non-Food Pruduce under Controlled Distribution\",\n \"970.000\": \"Import for Export\"\n },\n \"CPSC\": {\n \"081.001\": \"Import of a device, accessory, or component (regulated as a finished Medical Device) intended to be used as a finished medical device\",\n \"970.000\": \"For Export – if subcode below does not apply\"\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-shipment-intended-use-details/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Customs","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/shipment/intended-use-details</div>","section_slug":"get-shipment-intended-use-details","section_title":"Get intended-use details","summary":"API reference · Customs"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/shipment/citation-code-details\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/shipment/citation-code-details', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/shipment/citation-code-details', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/shipment/citation-code-details', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/shipment/citation-code-details');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/shipment/citation-code-details\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/citation-code-details\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/shipment/citation-code-details\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/shipment/citation-code-details')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/shipment/citation-code-details'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/shipment/citation-code-details\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/shipment/citation-code-details\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-shipment-citation-code-details\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/shipment/citation-code-details\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Get Citation Code Details</h2><div class=\"field-description\">Returns accepted citation codes and descriptions grouped by CertificateTypeCPC and CertificateTypeGCC.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>The endpoint prose and example use CertificateTypeCPC and CertificateTypeGCC. Its referenced schema uses CPC and GCC. This source inconsistency needs confirmation against your approved test account. Inspect the returned keys and keep a documented compatibility mapping instead of assuming one shape. Inner maps use citation description as the key and citation code as the value.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#customs\" data-topic=\"customs\">Cross-border & customs</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Map of certificate type to citation code map</summary><p class=\"field-description\">Map of certificate type to citation code map</p><h3>application/json</h3><p class=\"field-description\">Map of certificate type to a map of citation-description -> citation-code.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>CPC</code><span class=\"field-type\">CitationCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of citation description to citation code value.</p><p class=\"field-type\">example: <code>{\"4.1 - ASTM F963: Material quality\":\"4.1\",\"1203 - 16 CFR 1203: Safety Standard for Bicycle Helmets\":\"1203\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of citation description to citation code value.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">The citation code value.</p><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>GCC</code><span class=\"field-type\">CitationCodeMap</span><span class=\"field-required\">Required</span></div></summary><p class=\"field-description\">Map of citation description to citation code value.</p><p class=\"field-type\">example: <code>{\"4.1 - ASTM F963: Material quality\":\"4.1\",\"1203 - 16 CFR 1203: Safety Standard for Bicycle Helmets\":\"1203\"}</code></p><div class=\"field-children\"><p class=\"field-description\">Map of citation description to citation code value.</p><h3>Map values</h3><p>Keys map to the following value definition.</p><div class=\"field-children\"><p class=\"field-description\">The citation code value.</p><p class=\"field-type\">Type: string</p></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Map of certificate type to citation code map\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/CitationCodeDetailsMap\"\n },\n \"example\": {\n \"CertificateTypeCPC\": {\n \"4.1 - ASTM F963: Material quality\": \"4.1\",\n \"4.3.5.1(2) - ASTM F963: Paint and Similar Surface Coating Materials\": \"4.3.5.1(2)\",\n \"1203 - 16 CFR 1203: Safety Standard for Bicycle Helmets\": \"1203\",\n \"1307 - 16 CFR 1307: Prohibition of Children's Toys and Child Care Articles Containing Specified Phthalates\": \"1307\"\n },\n \"CertificateTypeGCC\": {\n \"1203 - 16 CFR 1203: Safety Standard for Bicycle Helmets\": \"1203\",\n \"1211 - 16 CFR 1211: Safety Standard for Automatic Residential Garage Door Operators\": \"1211\",\n \"1303 - 16 CFR 1303: Ban of Lead-Containing Paint and Certain Consumer Products Bearing Lead-Containing Paint\": \"1303\"\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-shipment-citation-code-details/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Customs","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/shipment/citation-code-details</div>","section_slug":"get-shipment-citation-code-details","section_title":"Get citation-code details","summary":"API reference · Customs"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/manifest\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/manifest', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/manifest', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/manifest', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/manifest');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/manifest\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/manifest\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/manifest\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/manifest')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/manifest'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/manifest\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/manifest\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-manifest\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/manifest\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"carrier_id\": \"REPLACE_WITH_CARRIER_ID\",\n \"manifest_data\": {\n \"tracking_numbers\": [\n \"REPLACE_WITH_TRACKING_NUMBER\"\n ],\n \"manifest_date\": {\n \"year\": 2026,\n \"month\": 10,\n \"day\": 28\n },\n \"origin_postal_code\": \"N2L 3G1\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Request a manifest</h2><div class=\"field-description\">Initiate a manifest request.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 202 returns request_id, used as manifest_id for retrieval. Supply the carrier_id confirmed for your integration. manifest_data requirements vary by carrier. tracking_numbers selects shipments. If that array is empty, manifest_date is used. origin_postal_code supports generation by shipping point.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><div class=\"field-item\"><div class=\"field-heading\"><code>carrier_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>manifest_data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\">Contains additional data that can be used to filter or limit the manifest request. Specific fields required depending upon the carrier.</p><div class=\"field-children\"><p class=\"field-description\">Contains additional data that can be used to filter or limit the manifest request. Specific fields required depending upon the carrier.</p><details class=\"field-item\"><summary><div class=\"field-heading\"><code>tracking_numbers</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The shipment details to get based on tracking numbers. If empty then manifest_date will be used instead.</p><div class=\"field-children\"><p class=\"field-description\">The shipment details to get based on tracking numbers. If empty then manifest_date will be used instead.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>manifest_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>origin_postal_code</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Used when generating manifest by shipping point.</p></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"carrier_id\": {\n \"type\": \"string\"\n },\n \"manifest_data\": {\n \"description\": \"Contains additional data that can be used to filter or limit the manifest request. Specific fields required depending upon the carrier.\",\n \"type\": \"object\",\n \"properties\": {\n \"tracking_numbers\": {\n \"type\": \"array\",\n \"description\": \"The shipment details to get based on tracking numbers. If empty then manifest_date will be used instead.\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"manifest_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"origin_postal_code\": {\n \"type\": \"string\",\n \"description\": \"Used when generating manifest by shipping point.\"\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 202 · Manifest generation initiated.</summary><p class=\"field-description\">Manifest generation initiated.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>request_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The manifest ID.</p></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"202\": {\n \"description\": \"Manifest generation initiated.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"request_id\": {\n \"type\": \"string\",\n \"description\": \"The manifest ID.\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-manifest/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Dispatch","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/manifest</div>","section_slug":"post-manifest","section_title":"Request a manifest","summary":"API reference · Dispatch"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-manifest-manifest-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/manifest/REPLACE_WITH_MANIFEST_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Retrieve a manifest</h2><div class=\"field-description\">Get the results of a manifest request.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>HTTP 202 means pending and has no declared JSON body. Poll with an overall deadline. HTTP 200 returns a url only if a manifest was generated. Handle a completed response with no URL and do not loop indefinitely waiting for one.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#polling\" data-topic=\"polling\">Polling, retries & recovery</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>manifest_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"manifest_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Result of the manifest request.</summary><p class=\"field-description\">Result of the manifest request.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>url</code><span class=\"field-type\">string</span></div><p class=\"field-description\">URL of the manifest, if one was generated, for downloading.</p></div></details><details class=\"response-status\" open=\"\"><summary>HTTP 202 · The request is pending, please try again shortly.</summary><p class=\"field-description\">The request is pending, please try again shortly.</p></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Result of the manifest request.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"url\": {\n \"type\": \"string\",\n \"description\": \"URL of the manifest, if one was generated, for downloading.\"\n }\n }\n }\n }\n }\n },\n \"202\": {\n \"description\": \"The request is pending, please try again shortly.\"\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-manifest-manifest-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Dispatch","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/manifest/{manifest_id}</div>","section_slug":"get-manifest-manifest-id","section_title":"Retrieve a manifest","summary":"API reference · Dispatch"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/payment-methods\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/payment-methods', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/payment-methods', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/payment-methods', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/payment-methods');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/payment-methods\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-methods\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/payment-methods\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/payment-methods')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/payment-methods'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-methods\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/payment-methods\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-methods\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/payment-methods\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>List payment methods</h2><div class=\"field-description\">Get the payment methods available for your account.\n\n**(UPDATED in 2.7.0)** If you have activated Prepaid Shipping in the customer portal, your credit card payment methods will still be returned,\nbut you can no longer use credit cards to book shipments.\nCredit cards can be used to reload your prepaid balance, and your prepaid payment method can be used to book shipments.\n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Returns an array of payment methods with id, type and label. After Prepaid Shipping activation, credit cards remain listed but are used for prepaid reloads, not shipment booking. Use the prepaid method for bookings. Do not infer eligibility from a credit card remaining in this list.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · All available payment methods.</summary><p class=\"field-description\">All available payment methods.</p><h3>application/json</h3><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Payment method ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The payment method type.</p><p class=\"field-type\">Values: <code>credit-card</code>, <code>net-terms</code>, <code>prepaid</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>label</code><span class=\"field-type\">string</span></div><p class=\"field-description\">For credit cards, this is the label as assigned through the customer portal. May be empty.\n\nFor other payment methods, this label is assigned by the system.\n</p></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"All available payment methods.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Payment method ID.\"\n },\n \"type\": {\n \"type\": \"string\",\n \"description\": \"The payment method type.\",\n \"enum\": [\n \"credit-card\",\n \"net-terms\",\n \"prepaid\"\n ]\n },\n \"label\": {\n \"type\": \"string\",\n \"description\": \"For credit cards, this is the label as assigned through the customer portal. May be empty.\\n\\nFor other payment methods, this label is assigned by the system.\\n\"\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-payment-methods/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/payment-methods</div>","section_slug":"get-finance-payment-methods","section_title":"List payment methods","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-payment-method-payment-method-id-available-balances\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/payment-method/REPLACE_WITH_PAYMENT_METHOD_ID/available-balances\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Check available balances</h2><div class=\"field-description\">Get the available balances for a Net Terms or Prepaid payment method.\n\n**(NEW in 2.7.0)**\n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Use a Net Terms or Prepaid payment method ID. available_balances is an array of Money objects. Net Terms has one balance shared across CAD and USD and its currency is absent. Prepaid has separate CAD and USD balances. Do not assign a currency to the Net Terms balance or merge the prepaid balances.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>payment_method_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The Net Terms or Prepaid payment method ID to get available balances for.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"payment_method_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The Net Terms or Prepaid payment method ID to get available balances for.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Payment method details and available balances.</summary><p class=\"field-description\">Payment method details and available balances.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Payment method ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The payment method type.</p><p class=\"field-type\">Values: <code>net-terms</code>, <code>prepaid</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>label</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The label assigned by the system to this payment method.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>available_balances</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The available balances. Will contain at least one object.\n\nA Net Terms payment method has a single balance that is used for both CAD and USD payments.\nThe balance has no currency.\n\nA Prepaid payment method has separate balances for CAD and USD payments.\n</p><div class=\"field-children\"><p class=\"field-description\">The available balances. Will contain at least one object.\n\nA Net Terms payment method has a single balance that is used for both CAD and USD payments.\nThe balance has no currency.\n\nA Prepaid payment method has separate balances for CAD and USD payments.\n</p><p class=\"field-type\">Array of Money</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Payment method details and available balances.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Payment method ID.\"\n },\n \"type\": {\n \"type\": \"string\",\n \"description\": \"The payment method type.\",\n \"enum\": [\n \"net-terms\",\n \"prepaid\"\n ]\n },\n \"label\": {\n \"type\": \"string\",\n \"description\": \"The label assigned by the system to this payment method.\"\n },\n \"available_balances\": {\n \"type\": \"array\",\n \"description\": \"The available balances. Will contain at least one object.\\n\\nA Net Terms payment method has a single balance that is used for both CAD and USD payments.\\nThe balance has no currency.\\n\\nA Prepaid payment method has separate balances for CAD and USD payments.\\n\",\n \"items\": {\n \"$ref\": \"#/components/schemas/Money\"\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-payment-method-payment-method-id-available-balances/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/payment-method/{payment_method_id}/available-balances</div>","section_slug":"get-finance-payment-method-payment-method-id-available-balances","section_title":"Check available balances","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"POST\"\nurl=\"https://external-api.freightcom.com/finance/reload-prepaid-balance\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'POST';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/reload-prepaid-balance', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'POST';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/reload-prepaid-balance', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'POST'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/reload-prepaid-balance', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'POST';\n$ch = curl_init('https://external-api.freightcom.com/finance/reload-prepaid-balance');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"POST\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/reload-prepaid-balance\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"POST\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/reload-prepaid-balance\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"POST\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/reload-prepaid-balance\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'POST'\nuri = URI('https://external-api.freightcom.com/finance/reload-prepaid-balance')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'POST'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/reload-prepaid-balance'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"POST\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/reload-prepaid-balance\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"POST\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/reload-prepaid-balance\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#post-finance-reload-prepaid-balance\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Save the code and JSON payload in the same directory. Replace sample dates, addresses and account IDs before running. This request charges a payment method. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"POST\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/reload-prepaid-balance\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"{\n \"from_payment_method_id\": \"REPLACE_WITH_CREDIT_CARD_ID\",\n \"amount\": {\n \"currency\": \"CAD\",\n \"value\": \"10000\"\n }\n}","file_name":"request.json","snippet_title":"request.json","syntax":"json","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Reload prepaid balance</h2><div class=\"field-description\">Reload your Prepaid balance from a credit card payment method with a one-time payment.\n\n**(NEW in 2.7.0)**\n\nThe amount currency, CAD or USD, will determine which currency will be charged to your credit card\nand which Prepaid balance the funds will be added to: your CAD balance or your USD balance.\n\nThis is a one-time transaction. You can set up automatic reload and email warnings in the customer portal.\n\nThe 200 response contains the amount that was reloaded, the Prepaid balance after the reload,\nand information about the credit card receipt generated for the transaction.\n\nIf another Prepaid activity occurs at the same time, such as booking a shipment or reloading twice with the same currency,\nthe `available_balance` in the response may reflect the balance before *or after* the other activity.\nIn this case, you can find accurate balances before and after each activity on your statement in the customer portal.\n</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file and its request.json payload.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>This charges the credit card identified by from_payment_method_id. amount.currency selects CAD or USD. amount.value is a string of minor units. HTTP 200 returns amount, available_balance, receipt_document_id and receipt_email_recipients. Concurrent activity affects the returned balance. Reconcile an uncertain result before another POST, since the specification does not declare an idempotency key for reloads.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>JSON body</h3><p class=\"muted\">Expand nested fields for their definitions. Conditional requirements also appear in field descriptions.</p><div class=\"field-item\"><div class=\"field-heading\"><code>from_payment_method_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The credit card payment method id that will be charged.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"from_payment_method_id\": {\n \"type\": \"string\",\n \"description\": \"The credit card payment method id that will be charged.\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n }\n }\n }\n }\n }\n}</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Prepaid balance reloaded successfully.</summary><p class=\"field-description\">Prepaid balance reloaded successfully.</p><h3>application/json</h3><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>available_balance</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>receipt_document_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The document id of the credit card receipt. You can get the receipt details and download URL from the `/finance/document/{document_id}` endpoint.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>receipt_email_recipients</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">The email addresses that the credit card receipt was emailed to.</p><div class=\"field-children\"><p class=\"field-description\">The email addresses that the credit card receipt was emailed to.</p><p class=\"field-type\">Array of string</p><div class=\"field-children\"><p class=\"field-type\">Type: string</p></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Prepaid balance reloaded successfully.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"available_balance\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"receipt_document_id\": {\n \"type\": \"string\",\n \"description\": \"The document id of the credit card receipt. You can get the receipt details and download URL from the `/finance/document/{document_id}` endpoint.\"\n },\n \"receipt_email_recipients\": {\n \"type\": \"array\",\n \"description\": \"The email addresses that the credit card receipt was emailed to.\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/post-finance-reload-prepaid-balance/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>POST</b>/finance/reload-prepaid-balance</div>","section_slug":"post-finance-reload-prepaid-balance","section_title":"Reload prepaid balance","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-documents\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/documents?start_date=REPLACE_WITH_START_DATE&end_date=REPLACE_WITH_END_DATE\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>List financial documents</h2><div class=\"field-description\">Get a list of documents in a date range.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Both start_date and end_date query parameters are required. Use YYYY-MM-DD dates interpreted in UTC. The endpoint prose describes a list but the response schema declares a single document object. Confirm the actual response shape through approved account testing before writing an array-only parser.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>start_date</code><span class=\"field-type\">query · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The start date in UTC to search in.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>end_date</code><span class=\"field-type\">query · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The end date in UTC.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"query\",\n \"name\": \"start_date\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The start date in UTC to search in.\",\n \"example\": \"2021-07-01\"\n },\n {\n \"in\": \"query\",\n \"name\": \"end_date\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The end date in UTC.\",\n \"example\": \"2021-07-31\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Documents in the time range.</summary><p class=\"field-description\">Documents in the time range.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Invoice ID.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\">The invoice type.</p></div><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Number for the invoice.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>due_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>owing</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Documents in the time range.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Invoice ID.\"\n },\n \"type\": {\n \"type\": \"string\",\n \"description\": \"The invoice type.\"\n },\n \"number\": {\n \"type\": \"string\",\n \"description\": \"Number for the invoice.\"\n },\n \"date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"due_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"owing\": {\n \"$ref\": \"#/components/schemas/Money\"\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-documents/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/documents</div>","section_slug":"get-finance-documents","section_title":"List financial documents","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-document-document-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/document/REPLACE_WITH_DOCUMENT_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Retrieve a financial document</h2><div class=\"field-description\">Get a particular document with details.</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Use the document ID. Inspect urls for available PDFs, plus payments and line_items. Preserve Money.value as a string of minor units and its currency. Treat document links and financial information as private.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>document_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The document to retrieve details on.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"document_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The document to retrieve details on.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Document with details.</summary><p class=\"field-description\">Document with details.</p><h3>application/json</h3><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>due_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>owing</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>urls</code><span class=\"field-type\">object</span></div><p class=\"field-description\">URLs where the PDF of the document can be downloaded.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>payments</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Payments made on the document.</p><div class=\"field-children\"><p class=\"field-description\">Payments made on the document.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_auth</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_reference</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>line_items</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>base</code>, <code>surcharge</code>, <code>tax</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>sub_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>payment_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>message</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Document with details.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"number\": {\n \"type\": \"string\"\n },\n \"date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"due_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"owing\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"urls\": {\n \"type\": \"object\",\n \"description\": \"URLs where the PDF of the document can be downloaded.\"\n },\n \"payments\": {\n \"type\": \"array\",\n \"description\": \"Payments made on the document.\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"data\": {\n \"type\": \"object\",\n \"properties\": {\n \"credit_card_auth\": {\n \"type\": \"string\"\n },\n \"credit_card_number\": {\n \"type\": \"string\"\n },\n \"credit_card_reference\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n },\n \"line_items\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"base\",\n \"surcharge\",\n \"tax\"\n ]\n },\n \"sub_type\": {\n \"type\": \"string\"\n },\n \"payment_id\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"message\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-document-document-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/document/{document_id}</div>","section_slug":"get-finance-document-document-id","section_title":"Retrieve a financial document","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-shipment-id-shipment-id\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/invoices-for-shipment-id/REPLACE_WITH_SHIPMENT_ID\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Find invoices by shipment</h2><div class=\"field-description\">Get invoices for the shipment id</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Returns an array of detailed invoice objects for the shipment ID. An invoice is not guaranteed to exist immediately after booking. Retrieve again later as needed without rebooking. Reconcile line_items, payments, amount and owing against the order.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>shipment_id</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The shipment id to retrieve invoices for.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"shipment_id\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The shipment id to retrieve invoices for.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Documents with details.</summary><p class=\"field-description\">Documents with details.</p><h3>application/json</h3><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>due_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>owing</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>urls</code><span class=\"field-type\">object</span></div><p class=\"field-description\">URLs where the PDF of the document can be downloaded.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>payments</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Payments made on the document.</p><div class=\"field-children\"><p class=\"field-description\">Payments made on the document.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_auth</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_reference</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>line_items</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>base</code>, <code>surcharge</code>, <code>tax</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>sub_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>payment_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>message</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Documents with details.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"number\": {\n \"type\": \"string\"\n },\n \"date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"due_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"owing\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"urls\": {\n \"type\": \"object\",\n \"description\": \"URLs where the PDF of the document can be downloaded.\"\n },\n \"payments\": {\n \"type\": \"array\",\n \"description\": \"Payments made on the document.\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"data\": {\n \"type\": \"object\",\n \"properties\": {\n \"credit_card_auth\": {\n \"type\": \"string\"\n },\n \"credit_card_number\": {\n \"type\": \"string\"\n },\n \"credit_card_reference\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n },\n \"line_items\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"base\",\n \"surcharge\",\n \"tax\"\n ]\n },\n \"sub_type\": {\n \"type\": \"string\"\n },\n \"payment_id\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"message\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-invoices-for-shipment-id-shipment-id/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/invoices-for-shipment-id/{shipment_id}</div>","section_slug":"get-finance-invoices-for-shipment-id-shipment-id","section_title":"Find invoices by shipment","summary":"API reference · Finance"},{"code_languages":[{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"curl","runtime_note":"Requires Bash and cURL 7.76+. Run: bash request.sh. Set FREIGHTCOM_TOKEN first.","snippets":[{"code_text":"#!/usr/bin/env bash\nset -euo pipefail\n: \"${FREIGHTCOM_TOKEN:?Set FREIGHTCOM_TOKEN}\"\nmethod=\"GET\"\nurl=\"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\"\nargs=(--silent --show-error --fail-with-body --max-time 30 --request \"$method\"\n --header \"Authorization: $FREIGHTCOM_TOKEN\" --header 'Content-Type: application/json')\nif [ \"$method\" = POST ]; then args+=(--data-binary @request.json); fi\ncurl \"${args[@]}\" --write-out '\\nHTTP %{http_code}\\n' \"$url\"\n","file_name":"request.sh","snippet_title":"request.sh","syntax":"bash","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"javascript","runtime_note":"Requires Node.js 20+. Run: node request.mjs. No packages required.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nconst token = process.env.FREIGHTCOM_TOKEN;\nif (!token) throw new Error('Set FREIGHTCOM_TOKEN');\nconst method = 'GET';\nconst body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\nif (body) JSON.parse(body);\nconst response = await fetch('https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n});\nconsole.log('HTTP', response.status);\nconst text = await response.text();\nif (!response.ok) throw new Error(`Request failed (${response.status}): ${text}`);\nconsole.log(text);\n// HTTP 202 means accepted, not completed. Follow the polling guide.\n","file_name":"request.mjs","snippet_title":"request.mjs","syntax":"javascript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"typescript","runtime_note":"Requires Node.js 20+. Install TypeScript and Node types: npm install --save-dev typescript @types/node. In a directory without a tsconfig.json, compile: npx tsc request.ts --target ES2022 --module NodeNext --types node. Run: node request.js.","snippets":[{"code_text":"import { readFileSync } from 'node:fs';\nasync function main(): Promise<void> {\n const token = process.env.FREIGHTCOM_TOKEN;\n if (!token) throw new Error('Set FREIGHTCOM_TOKEN');\n const method: string = 'GET';\n const body = method === 'POST' ? readFileSync('request.json', 'utf8') : undefined;\n if (body) JSON.parse(body);\n const response = await fetch('https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER', {\n method, headers: { Authorization: token, 'Content-Type': 'application/json' },\n body, signal: AbortSignal.timeout(30000)\n });\n const text = await response.text();\n console.log('HTTP', response.status);\n if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);\n console.log(text);\n}\nmain().catch(error => { console.error(error); process.exitCode = 1; });\n","file_name":"request.ts","snippet_title":"request.ts","syntax":"typescript","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"python","runtime_note":"Requires Python 3.10+. Run: python request.py. Uses the standard library.","snippets":[{"code_text":"import json, os, urllib.request, urllib.error\n\ntoken = os.environ.get('FREIGHTCOM_TOKEN')\nif not token:\n raise RuntimeError('Set FREIGHTCOM_TOKEN')\nmethod = 'GET'\ndata = None\nif method == 'POST':\n with open('request.json', encoding='utf-8') as source:\n data = json.dumps(json.load(source)).encode('utf-8')\nrequest = urllib.request.Request(\n 'https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER', data=data, method=method,\n headers={'Authorization': token, 'Content-Type': 'application/json'})\ntry:\n with urllib.request.urlopen(request, timeout=30) as response:\n print('HTTP', response.status)\n print(response.read().decode('utf-8'))\nexcept urllib.error.HTTPError as error:\n raise RuntimeError(f'HTTP {error.code}: {error.read().decode()}') from error\n# HTTP 202 means accepted. Follow the workflow guide to poll for completion.\n","file_name":"request.py","snippet_title":"request.py","syntax":"python","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"php","runtime_note":"Requires PHP 8+ with cURL. Run: php request.php.","snippets":[{"code_text":"<?php\n$token = getenv('FREIGHTCOM_TOKEN');\nif (!$token) { throw new RuntimeException('Set FREIGHTCOM_TOKEN'); }\n$method = 'GET';\n$ch = curl_init('https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER');\ncurl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method,\n CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTPHEADER => ['Authorization: ' . $token, 'Content-Type: application/json']]);\nif ($method === 'POST') {\n $body = file_get_contents('request.json');\n if ($body === false) { throw new RuntimeException('Read request.json failed'); }\n json_decode($body, true, 512, JSON_THROW_ON_ERROR);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n}\n$result = curl_exec($ch);\nif ($result === false) { throw new RuntimeException(curl_error($ch)); }\n$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);\ncurl_close($ch);\nif ($status < 200 || $status >= 300) { throw new RuntimeException(\"HTTP $status: $result\"); }\necho \"HTTP $status\\n$result\\n\";\n","file_name":"request.php","snippet_title":"request.php","syntax":"php","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"csharp","runtime_note":"Requires .NET 8 SDK. Save Program.cs and FreightcomExample.csproj together, then run dotnet run.","snippets":[{"code_text":"using System;\nusing System.IO;\nusing System.Net.Http;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading.Tasks;\n\nvar token = Environment.GetEnvironmentVariable(\"FREIGHTCOM_TOKEN\")\n ?? throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nif (string.IsNullOrWhiteSpace(token)) throw new Exception(\"Set FREIGHTCOM_TOKEN\");\nvar method = \"GET\";\nusing var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };\nusing var request = new HttpRequestMessage(new HttpMethod(method),\n \"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\");\nrequest.Headers.Add(\"Authorization\", token);\nif (method == \"POST\") {\n var body = await File.ReadAllTextAsync(\"request.json\");\n using var parsed = JsonDocument.Parse(body);\n request.Content = new StringContent(body, Encoding.UTF8, \"application/json\");\n}\nusing var response = await client.SendAsync(request);\nvar text = await response.Content.ReadAsStringAsync();\nConsole.WriteLine($\"HTTP {(int)response.StatusCode}\");\nif (!response.IsSuccessStatusCode) throw new Exception(text);\nConsole.WriteLine(text);\n","file_name":"Program.cs","snippet_title":"Program.cs","syntax":"csharp","terminal_command":""},{"code_text":"<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n","file_name":"FreightcomExample.csproj","snippet_title":"FreightcomExample.csproj","syntax":"xml","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"java","runtime_note":"Requires Java 17+. Run: javac Request.java, then java Request.","snippets":[{"code_text":"import java.net.URI;\nimport java.net.http.*;\nimport java.nio.file.*;\nimport java.time.Duration;\n\npublic class Request {\n public static void main(String[] args) throws Exception {\n String token = System.getenv(\"FREIGHTCOM_TOKEN\");\n if (token == null || token.isBlank()) throw new IllegalStateException(\"Set FREIGHTCOM_TOKEN\");\n String method = \"GET\";\n var body = method.equals(\"POST\")\n ? HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n : HttpRequest.BodyPublishers.noBody();\n var request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build();\n var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();\n var response = client.send(request, HttpResponse.BodyHandlers.ofString());\n System.out.println(\"HTTP \" + response.statusCode());\n if (response.statusCode() < 200 || response.statusCode() >= 300)\n throw new IllegalStateException(response.body());\n System.out.println(response.body());\n }\n}\n","file_name":"Request.java","snippet_title":"Request.java","syntax":"java","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"go","runtime_note":"Requires Go 1.20+. Run: go run request.go. No third-party modules required.","snippets":[{"code_text":"package main\nimport (\n \"bytes\"\n \"encoding/json\"\n \"fmt\"\n \"io\"\n \"net/http\"\n \"os\"\n \"time\"\n)\nfunc main() {\n token := os.Getenv(\"FREIGHTCOM_TOKEN\")\n if token == \"\" { panic(\"Set FREIGHTCOM_TOKEN\") }\n method := \"GET\"\n var body []byte\n var err error\n if method == \"POST\" {\n body, err = os.ReadFile(\"request.json\")\n if err != nil { panic(err) }\n if !json.Valid(body) { panic(\"Invalid request.json\") }\n }\n req, err := http.NewRequest(method, \"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\", bytes.NewReader(body))\n if err != nil { panic(err) }\n req.Header.Set(\"Authorization\", token)\n req.Header.Set(\"Content-Type\", \"application/json\")\n client := &http.Client{Timeout: 30 * time.Second}\n res, err := client.Do(req)\n if err != nil { panic(err) }\n defer res.Body.Close()\n data, err := io.ReadAll(res.Body)\n if err != nil { panic(err) }\n fmt.Println(\"HTTP\", res.StatusCode)\n if res.StatusCode < 200 || res.StatusCode >= 300 { panic(string(data)) }\n fmt.Println(string(data))\n}\n","file_name":"request.go","snippet_title":"request.go","syntax":"go","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"ruby","runtime_note":"Requires Ruby 3+. Run: ruby request.rb. Uses standard-library HTTP and JSON.","snippets":[{"code_text":"require 'net/http'\nrequire 'json'\nrequire 'uri'\ntoken = ENV.fetch('FREIGHTCOM_TOKEN')\nraise 'Set FREIGHTCOM_TOKEN' if token.empty?\nmethod = 'GET'\nuri = URI('https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER')\nrequest_class = {'GET' => Net::HTTP::Get, 'POST' => Net::HTTP::Post, 'DELETE' => Net::HTTP::Delete}.fetch(method)\nrequest = request_class.new(uri)\nrequest['Authorization'] = token\nrequest['Content-Type'] = 'application/json'\nif method == 'POST'\n request.body = JSON.generate(JSON.parse(File.read('request.json')))\nend\nresponse = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true,\n open_timeout: 15, read_timeout: 30, write_timeout: 30) { |http| http.request(request) }\nputs \"HTTP #{response.code}\"\nraise response.body unless response.is_a?(Net::HTTPSuccess)\nputs response.body\n","file_name":"request.rb","snippet_title":"request.rb","syntax":"ruby","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"powershell","runtime_note":"Requires PowerShell 7+. Run: pwsh -File request.ps1.","snippets":[{"code_text":"$ErrorActionPreference = 'Stop'\nif (-not $env:FREIGHTCOM_TOKEN) { throw 'Set FREIGHTCOM_TOKEN' }\n$method = 'GET'\n$params = @{\n Uri = 'https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER'\n Method = $method\n Headers = @{ Authorization = $env:FREIGHTCOM_TOKEN }\n ContentType = 'application/json; charset=utf-8'\n TimeoutSec = 30\n SkipHttpErrorCheck = $true\n}\nif ($method -eq 'POST') {\n $body = Get-Content -Raw -Encoding utf8 request.json\n $null = $body | ConvertFrom-Json\n $params.Body = [System.Text.Encoding]::UTF8.GetBytes($body)\n}\n$response = Invoke-WebRequest @params\nWrite-Output \"HTTP $($response.StatusCode)\"\nif ($response.StatusCode -lt 200 -or $response.StatusCode -ge 300) { throw $response.Content }\nWrite-Output $response.Content\n","file_name":"request.ps1","snippet_title":"request.ps1","syntax":"powershell","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"kotlin","runtime_note":"Requires Kotlin and JDK 17+. Compile: kotlinc Request.kt -include-runtime -d request.jar. Run: java -jar request.jar.","snippets":[{"code_text":"import java.net.URI\nimport java.net.http.HttpClient\nimport java.net.http.HttpRequest\nimport java.net.http.HttpResponse\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.time.Duration\n\nfun main() {\n val token = System.getenv(\"FREIGHTCOM_TOKEN\")?.takeIf { it.isNotBlank() }\n ?: error(\"Set FREIGHTCOM_TOKEN\")\n val method = \"GET\"\n val body = if (method == \"POST\")\n HttpRequest.BodyPublishers.ofString(Files.readString(Path.of(\"request.json\")))\n else HttpRequest.BodyPublishers.noBody()\n val request = HttpRequest.newBuilder(URI.create(\"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\"))\n .timeout(Duration.ofSeconds(30)).header(\"Authorization\", token)\n .header(\"Content-Type\", \"application/json\").method(method, body).build()\n val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build()\n val response = client.send(request, HttpResponse.BodyHandlers.ofString())\n println(\"HTTP ${response.statusCode()}\")\n check(response.statusCode() in 200..299) { response.body() }\n println(response.body())\n}\n","file_name":"Request.kt","snippet_title":"Request.kt","syntax":"kotlin","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"swift","runtime_note":"Requires Swift 5.9+. Compile: swiftc -parse-as-library Request.swift -o request. Run: ./request. Keep credentials on a server, never in a distributed mobile app.","snippets":[{"code_text":"import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n@main struct RequestClient {\n static func main() async throws {\n guard let token = ProcessInfo.processInfo.environment[\"FREIGHTCOM_TOKEN\"], !token.isEmpty else {\n throw NSError(domain: \"Set FREIGHTCOM_TOKEN\", code: 1)\n }\n let method = \"GET\"\n var request = URLRequest(url: URL(string: \"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\")!)\n request.httpMethod = method\n request.timeoutInterval = 30\n request.setValue(token, forHTTPHeaderField: \"Authorization\")\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n if method == \"POST\" {\n let body = try Data(contentsOf: URL(fileURLWithPath: \"request.json\"))\n _ = try JSONSerialization.jsonObject(with: body)\n request.httpBody = body\n }\n let (data, response) = try await URLSession.shared.data(for: request)\n guard let http = response as? HTTPURLResponse else { throw URLError(.badServerResponse) }\n print(\"HTTP \\(http.statusCode)\")\n let text = String(decoding: data, as: UTF8.self)\n guard (200...299).contains(http.statusCode) else {\n throw NSError(domain: text, code: http.statusCode)\n }\n print(text)\n }\n}\n","file_name":"Request.swift","snippet_title":"Request.swift","syntax":"swift","terminal_command":""}]},{"instructions_html":"<p class=\"portal-example-reference\"><a href=\"#get-finance-invoices-for-transaction-number-transaction-number\">Link to this example</a></p>","introduction":"Set FREIGHTCOM_TOKEN on your server. Replace sample dates, addresses and account IDs before running. Use issued test tokens during integration and follow the testing instructions provided with them. Use live tokens only after testing is complete.","language_key":"rust","runtime_note":"Requires Rust and Cargo. Save main.rs and Cargo.toml together in one directory, then run cargo run. Cargo downloads reqwest and its dependencies on the first run.","snippets":[{"code_text":"use std::{env, fs, time::Duration};\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let token = env::var(\"FREIGHTCOM_TOKEN\")?;\n if token.is_empty() { return Err(\"Set FREIGHTCOM_TOKEN\".into()); }\n let method = \"GET\";\n let client = reqwest::blocking::Client::builder().timeout(Duration::from_secs(30)).build()?;\n let mut request = client.request(method.parse()?, \"https://external-api.freightcom.com/finance/invoices-for-transaction-number/REPLACE_WITH_TRANSACTION_NUMBER\")\n .header(\"Authorization\", token).header(\"Content-Type\", \"application/json\");\n if method == \"POST\" { request = request.body(fs::read_to_string(\"request.json\")?); }\n let response = request.send()?;\n let status = response.status();\n let text = response.text()?;\n println!(\"HTTP {}\", status);\n if !status.is_success() { return Err(format!(\"HTTP {}: {}\", status, text).into()); }\n println!(\"{}\", text);\n Ok(())\n}\n","file_name":"main.rs","snippet_title":"main.rs","syntax":"rust","terminal_command":""},{"code_text":"[package]\nname = \"freightcom-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[[bin]]\nname = \"freightcom-example\"\npath = \"main.rs\"\n[dependencies]\nreqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n","file_name":"Cargo.toml","snippet_title":"Cargo.toml","syntax":"ini","terminal_command":""}]}],"content_blocks":[{"block_title":"Overview","rich_content":"<h2>Find invoices by transaction</h2><div class=\"field-description\">Get invoices for the shipment transaction number</div><div class=\"doc-callout\"><strong>Use this example</strong><ol><li>Set your API token in the server environment.</li><li>Copy the selected language file.</li><li>Replace sample values, then follow the runtime instructions beside the code.</li><li>Inspect the response status and follow the completion rules below.</li></ol></div><h3>Completion & handling</h3><p>Returns an array of detailed invoices for a shipment transaction number. Use shipment.transaction_number from the retrieved shipment. Do not substitute a tracking number or shipment ID. URL-encode a dynamic transaction number as a single path segment.</p><h3>Related guidance</h3><div class=\"topic-links\"><a href=\"#payments\" data-topic=\"payments\">Payments & money</a></div>"},{"block_title":"Request fields","rich_content":"<h2>Request fields</h2><h3>Path & query parameters</h3><div class=\"field-item\"><div class=\"field-heading\"><code>transaction_number</code><span class=\"field-type\">path · string</span><span class=\"field-required\">Required</span></div><p class=\"field-description\">The transaction number to retrieve invoices for.</p></div><p>This operation does not declare a JSON request body.</p><details class=\"full-spec\"><summary>Original specification definition</summary><pre>[\n {\n \"in\": \"path\",\n \"name\": \"transaction_number\",\n \"schema\": {\n \"type\": \"string\"\n },\n \"required\": true,\n \"description\": \"The transaction number to retrieve invoices for.\"\n }\n]</pre></details>"},{"block_title":"Responses","rich_content":"<h2>Response definitions</h2><p>These definitions come from the specification. They are not captured account responses.</p><details class=\"response-status\" open=\"\"><summary>HTTP 200 · Documents with details.</summary><p class=\"field-description\">Documents with details.</p><h3>application/json</h3><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>due_date</code><span class=\"field-type\">Date</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>year</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>2006</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>month</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>6</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>day</code><span class=\"field-type\">integer</span><span class=\"field-required\">Required</span></div><p class=\"field-description\"></p><p class=\"field-type\">example: <code>7</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>owing</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>urls</code><span class=\"field-type\">object</span></div><p class=\"field-description\">URLs where the PDF of the document can be downloaded.</p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>payments</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\">Payments made on the document.</p><div class=\"field-children\"><p class=\"field-description\">Payments made on the document.</p><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>data</code><span class=\"field-type\">object</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_auth</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_number</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>credit_card_reference</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></details></div></div></details><details class=\"field-item\"><summary><div class=\"field-heading\"><code>line_items</code><span class=\"field-type\">array</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><p class=\"field-type\">Array of object</p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p><p class=\"field-type\">Values: <code>base</code>, <code>surcharge</code>, <code>tax</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>sub_type</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>payment_id</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div><details class=\"field-item\"><summary><div class=\"field-heading\"><code>amount</code><span class=\"field-type\">Money</span></div></summary><p class=\"field-description\"></p><div class=\"field-children\"><div class=\"field-item\"><div class=\"field-heading\"><code>currency</code><span class=\"field-type\">string</span></div><p class=\"field-description\">ISO 4217 alpha code of the currency such as: CAD, USD, EUR, INR, etc.\n</p><p class=\"field-type\">example: <code>CAD</code></p></div><div class=\"field-item\"><div class=\"field-heading\"><code>value</code><span class=\"field-type\">string</span></div><p class=\"field-description\">Value in the lowest common indivisible unit of the currency, e.g. cents. 42.50 CAD would be represented as 4250.\n</p><p class=\"field-type\">example: <code>4250</code></p></div></div></details><div class=\"field-item\"><div class=\"field-heading\"><code>message</code><span class=\"field-type\">string</span></div><p class=\"field-description\"></p></div></div></div></details></div></details><details class=\"full-spec\"><summary>Original specification definition</summary><pre>{\n \"200\": {\n \"description\": \"Documents with details.\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"number\": {\n \"type\": \"string\"\n },\n \"date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"due_date\": {\n \"$ref\": \"#/components/schemas/Date\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"owing\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"urls\": {\n \"type\": \"object\",\n \"description\": \"URLs where the PDF of the document can be downloaded.\"\n },\n \"payments\": {\n \"type\": \"array\",\n \"description\": \"Payments made on the document.\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"data\": {\n \"type\": \"object\",\n \"properties\": {\n \"credit_card_auth\": {\n \"type\": \"string\"\n },\n \"credit_card_number\": {\n \"type\": \"string\"\n },\n \"credit_card_reference\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n },\n \"line_items\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"base\",\n \"surcharge\",\n \"tax\"\n ]\n },\n \"sub_type\": {\n \"type\": \"string\"\n },\n \"payment_id\": {\n \"type\": \"string\"\n },\n \"amount\": {\n \"$ref\": \"#/components/schemas/Money\"\n },\n \"message\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}</pre></details>"}],"legacy_paths":"/developers/api/get-finance-invoices-for-transaction-number-transaction-number/","media":{"alt":"","src":""},"media_caption":"","navigation_group":"Finance","rich_content":"<div class=\"endpoint-pill\"><b>GET</b>/finance/invoices-for-transaction-number/{transaction_number}</div>","section_slug":"get-finance-invoices-for-transaction-number-transaction-number","section_title":"Find invoices by transaction","summary":"API reference · Finance"}],"settings":{"alternate_url":"/fr/developpeurs/guides","code_navigation_label":"Example files","copied_message":"Copied to clipboard.","copy_button_label":"Copy","copy_failed_message":"Clipboard access is unavailable. Select the code or use Download.","copy_link_button_label":"Copy page link","default_language_key":"javascript","default_section":"quickstart","disclaimer_html":"<h2>Important: refer to the official API documentation</h2><p>These guides, sample code and downloads are for informational purposes only. Always refer to the official Freightcom API documentation for current requirements. If these resources differ from the official documentation, the official documentation takes precedence. Validate your integration before use.</p><p class=\"resource-liability\"><strong>Disclaimer.</strong> These resources are provided “as is”, without warranties of accuracy, completeness or fitness for a particular purpose. To the fullest extent permitted by applicable law, Freightcom Inc. disclaims all liability for losses, damages or costs arising from your use of, or reliance on, these resources. Your use of Freightcom services remains subject to the applicable agreements and terms.</p>","download_button_label":"Download","empty_code_message":"No code examples are available for this section.","empty_search_message":"No matching resources. Try another search.","empty_sections_message":"No documentation sections are available.","examples_prefix":"Examples in","footer_html":"<p>Freightcom Customer API v2.10.0 · Examples require your account details. Live account validation remains required.</p>","invalid_model_message":"Developer resources could not load. Please refer to the official API documentation.","language_heading":"Build in your language","language_help":"Examples update across the workspace","language_navigation_label":"Code language","loading_message":"Loading developer resources…","locale":"en","menu_button_label":"Browse resources","missing_language_message":"{preferred} is not available in this section. Showing {shown}. Your preference is retained.","next_label":"Next","no_script_message":"Enable JavaScript to use the interactive Developer Portal, or open the official API documentation.","official_doc_label":"Official API Documentation","official_doc_link":{"no_follow":false,"open_in_new_tab":true,"rel":"noopener","sponsored":false,"url":{"content_id":null,"href":"https://developer.freightcom.com/","href_with_scheme":"https://developer.freightcom.com/","type":"EXTERNAL"},"user_generated_content":false},"portal_heading":"Developer Centre","portal_summary":"Freightcom Shipping API documentation, request examples and integration guidance.","previous_label":"Previous","same_url":"/developers/guides","search_label":"Search documentation","search_placeholder":"Search guides, endpoints or fields…","section_navigation_label":"Developer documentation"}}