Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/plantasur-dev/ship-quote/llms.txt

Use this file to discover all available pages before exploring further.

Creating an agency is the first step to adding a carrier to the rate comparison engine. Each agency record stores the routing rules, shipment capabilities, pricing supplements, and — when the carrier exposes its own HTTP API — the credentials and endpoint map needed to query it in real time.
The code field is automatically derived from name by the API (lower-cased, diacritics stripped, spaces replaced with _). It is not accepted as a request body field — the server always computes it from name.

Endpoint

POST /api/v1/agencies

Request Body

name
string
required
Human-readable agency name. Must be between 3 and 14 characters. The value is title-cased automatically (e.g. "dachser" is stored as "Dachser").
type
string
default:"static"
Determines how the rate engine sources prices for this agency. Accepted values:
ValueDescription
"static"Rates are read from locally stored zone and rate documents in MongoDB.
"api"Rates are fetched in real time from the carrier’s external HTTP API. apiConfig is required.
"hybrid"Both static and API sources are used. apiConfig is required.
rules
object
Routing and capability rules applied during rate comparison.
supplements
object
Pricing supplements applied on top of the base rate.
apiConfig
object
Carrier API connection details. Required when type is "api" or "hybrid". Ignored for "static" agencies.

Response

A successful request returns HTTP 201 Created with the full agency document.
id
string
MongoDB ObjectId of the newly created agency.
name
string
Title-cased agency name as stored.
code
string
Normalised slug identifier derived from name.
type
string
Agency type: "static", "api", or "hybrid".
active
boolean
true if the agency is included in rate comparisons.
rules
object
Capability and routing rules as stored.
supplements
object
Stored supplement configuration.
apiConfig
object
Carrier API configuration (present for "api" and "hybrid" agencies).
createdAt
string
ISO 8601 timestamp of when the agency was created.
updatedAt
string
ISO 8601 timestamp of the last update.

Examples

The following example creates Dachser as an "api" agency that covers both national and international shipments, bills a 5.5 % fuel surcharge, and handles pallets only.
curl -X POST http://localhost:3000/api/v1/agencies \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Dachser",
    "type": "api",
    "rules": {
      "hasAndaluciaRule": false,
      "supportsPallets": true,
      "supportsParcels": false,
      "coverage": ["national", "international"]
    },
    "supplements": {
      "fuelSurcharge": {
        "enabled": true,
        "type": "percentage",
        "value": 5.5
      }
    },
    "apiConfig": {
      "baseUrlApi": "https://api.dachser.com",
      "timeout": 5000,
      "apiKey": "sk_live_xxxxx",
      "endpoints": {
        "quotations": "/v2/quotations",
        "transportOrders": "/v2/orders"
      }
    }
  }'

Error Responses

400 Bad Request
object
Returned when a required field is missing or a value fails Mongoose schema validation (e.g. name shorter than 3 characters, unrecognised type value, or missing baseUrlApi for an "api" agency).
{
  "message": "Name is required"
}
409 Conflict
object
Returned when an agency with the same code already exists. Agency codes are derived from name and enforced as unique by a MongoDB index.
{
  "message": "Resource duplicate"
}

Build docs developers (and LLMs) love