• Introduction
    • Getting Started
    • Authentication
    • Error Handling
    • Contact Support
    • Modaltrans API
      • Get Auth Token
        • Get Bearer Token
      • Accounting
        • Invoices
          • Retrieve an Invoice
          • List all Invoices
        • Invoice Items
          • List all Invoice Items
          • Deleted Invoice Items
        • Financials
          • Retrieve Financial Information
      • Customs
        • NCTS Declarations
          • List all NCTS Declarations
          • Retrieve an NCTS Declaration
          • Create an NCTS Declaration with XML Data
          • Update an NCTS Declaration
          • Download an NCTS Declaration
          • List Timelines of NCTS Declaration
          • List Messages of NCTS Decalaration
        • Customs Declarations
          • List all Customs Declarations
          • Retrieve a Custom Declaration
          • Create a Customs Declaration
          • Update a Custom Declaration
          • Delete a Custom Declaration
          • Retrieve a Declaration History
          • Retrieve an MRN Status of Declaration
        • Declaration Requests
          • List all Declaration Orders
          • Retrieve a Declaration Request
          • Create a Declaration Request
          • Update a Declaration Request
          • Delete a Declaration Request
        • Ens Declarations
          • Create an Ens Declaration
          • Download an Ens Declaration
      • Logistics
        • Bookings
          • Retrieve a Booking
          • List all Bookings
          • Create a Booking
          • Update a Booking
        • Locations
          • List all Locations
          • Retrieve a Location
        • Positions
          • Update a Transport
          • Get All Positions
          • Retrieve a Position
        • Tracking
          • Available Shipping Lines
          • Retrieve a Tracking Data
          • Subscribe to Tracking
        • Shipments
          • Retrieve a Shipment
          • List All Shipments
          • Retrieve Financials of Shipment
          • List Contacts of the Shipment
          • Create a Shipment
          • Update a Shipment
      • Depot
        • Orders
          • Retrieve an Order
          • List all Orders
          • Create an Order
          • Update an Order
        • Products
          • Retrieve a Product
          • List all Products
          • Create a Product
          • Update a Product
          • List Product Stocks
        • Inventories
          • List all Inventories
      • Fleet Management
        • Drivers
          • Retrieve a Driver
          • Retrieve a Driver's Vehicle
          • List Driver Positions
          • Update a Driver
        • Vehicles
          • Retrieve a Vehicle
          • Update a Vehicle
        • Gps Service Controller
          • Create Gps Responses
        • Service Logs
          • List all Service Logs
          • Retrieve a Service Log
          • Create a Service Log
          • Delete a Service Log
          • Update a Service Log
        • Periodic Documents
          • Retrieve a Periodic Document
          • Update a Periodic Document
          • Create a Periodic Document
      • CRM
        • Companies
          • List all Companies
          • Retrieve a Company
          • Create a Company
          • Update a Company
          • Delete a Company
          • List Company Credit Limits
        • Quotes
          • Retrieve a Quote
          • List All Quotes
          • Update a Quote
          • Create a Quote
          • Accept a Quote
          • Reject a Quote
      • Timelines
        • Retrieve a Timeline
        • List Timelines
        • Create a Timeline
      • S3 Files
        • List all S3Files
        • Create an S3File
        • Delete an S3File
      • Notifications
        • List all Notifications
        • Update a Notification Status
      • User Details
        • List User Details
        • Update User Details
      • Milestones
        • Retrieve a Milestone
        • List Milestones
        • Create a Milestone
        • Delete a Milestone
        • Update a Milestone
    • Webhooks
      • Webhooks
      • Trackings
        • Tracking Webhooks
        • Sea
          • Sea Tracking Event Created
          • Sea Tracking Event Updated
        • Air
          • Air Tracking Event Created
          • Air Tracking Event Updated
      • Customs
        • Customs Declaration Status Changed
        • NCTS Declaration Status Changed
        • ENS Declaration Status Changed
        • GVMS Declaration Status Changed

    Authentication

    The Modaltrans API requires JWT Bearer tokens for authentication, which are obtained by logging in with the email and password of your API user. If the credentials are incorrect, the API will return a '403 Forbidden' error. Tokens are valid for 24 hours, after which a new token must be generated.
    Please use the "Get Bearer Token" method under the "Get Auth Token" collection.

    UpdateGettingStarted1.png

    Send the token in the Authorization header of every request:

    Security Considerations#

    When interacting with the Modaltrans API using JWT Bearer tokens, it's important to follow these security best practices to protect your application and data:

    Securely Store the JWT Token
    Once you receive a JWT Bearer token from the Modaltrans API, ensure it is stored securely. Do not store the token in places accessible to JavaScript, such as local storage or session storage.
    Token Expiry and Renewal
    JWT tokens provided by the Modaltrans API are valid for 24 hours. There is no refresh endpoint: when a token expires, log in again with the "Get Bearer Token" method to get a new one. Requesting a new token shortly before the current one expires ensures continuous access to the API.
    Do Not Share Your JWT Token
    Treat your JWT token like a password. Do not share it publicly or hard-code it in client-side code, as this could allow unauthorized access to your API.

    By following these security considerations, you can help ensure that JWTs are used safely and effectively within your applications.

    Authentication error response#

    When interacting with the Modaltrans API, authentication is a crucial step. If the API cannot authenticate you, you will receive an HTTP 403 Forbidden response. This applies both to the login request and to any other request sent with a missing, invalid, or expired token.

    Possible Causes of HTTP 403 Response When Logging In:#

    Incorrect Credentials: The email or password provided is incorrect, or the account is not an API user.
    Account Disabled: The user account or your company's Modaltrans account is not active.
    IP Restriction: Your API user is restricted to specific IP addresses and the request comes from a different one.

    Possible Causes of HTTP 403 Response on Other Requests:#

    Missing Token: The Authorization header is not included in the request.
    Invalid Token: The token is malformed or has expired.

    Example of an Authentication Error Response#

    When an authentication error occurs, the API response will include details about the failure. Below are examples of typical error responses:

    Invalid login credentials
    {
      "error": {
        "user_authentication": [
          "Invalid login credentials"
        ]
      }
    }
    Missing, invalid, or expired token
    {
      "error": "Invalid Authorization Token"
    }

    How to Handle Authentication Errors:#

    Verify Credentials: Double-check that the email and password being sent are correct and formatted properly. Ensure that any required fields are not missing.
    Check Token Validity: Ensure that the token is sent as Bearer <your_token> in the Authorization header and that it is not expired. If it has expired, log in again to get a new token.

    If you need help or have any questions, please Contact our support team.

    Modified at 2026-10-16 07:04:20
    Previous
    Getting Started
    Next
    Error Handling
    Built with