Carrier requests

Whether a label, void, manifest, tender or bill-of-lading request succeeded, failed or is Uncertain, and what may run next.

Request with "decision": "carrier" and one of these operations: LabelCreate, LabelVoid, ManifestSubmit, TenderRegister, BOLCreate.

Clauses applied

  • carrier.freeze: A carrier operation freezes its RequestKey and digest.
  • carrier.reprint: Reprint does not buy another label.
  • carrier.uncertain: A lost or timed-out response is Uncertain, not a confirmed failure. The original request identity is reused only when the verified connector supports idempotency; otherwise query/reconcile before another potentially billable creation.
  • carrier.retry: Known rejection may be retried according to the connector contract; timeout/unknown result requires lookup or reconciliation, not a new billable create.
  • carrier.reissue: Confirmed void or supported reconciliation precedes reissue; voiding a label does not itself change stock.

Evidence questions

carrier_outcome@1

This is the carrier's reply, error or lookup result for one request. Did the carrier carry out the requested operation?

AnswerMeaning
performedYes. The carrier created what was requested (label, void, manifest, tender or bill of lading), or reports that it already exists for this request.
not_performedNo. The carrier refused or never processed the request and nothing was created, or a lookup finds no such request.
not_establishedUnknown. The evidence does not settle it, such as a timeout, dropped connection, gateway error or ambiguous reply after the request was sent.

Examples

A label request whose reply was lost

{
  "decision": "carrier",
  "proposal": {
    "operation": "LabelCreate",
    "key": "CR-0413",
    "digest": "c7e1f0"
  },
  "connector": {
    "carrier": "UPS",
    "idempotency": "unverified",
    "lookup": "verified"
  },
  "requests": [
    {
      "key": "CR-0412",
      "digest": "c7e1f0",
      "operation": "LabelCreate",
      "attempts": [
        {
          "kind": "request",
          "transport": "sent",
          "at": "2026-10-02T14:02:11Z",
          "evidence": "POST /api/shipments/v2409/ship: read timed out after 30000 ms; request body fully written"
        }
      ]
    }
  ]
}

Response from the rules with no model loaded, so every question abstains.

{
  "verdict": "reconcile",
  "state": "Uncertain",
  "next": {
    "action": "lookup",
    "text": "Look up request CR-0412 with the carrier and record what it finds before anything billable runs again."
  },
  "questions": [
    {
      "ask": "requests/0/attempts/0",
      "question": "carrier_outcome@1",
      "status": "model_unavailable",
      "evidence": [
        "/requests/0/attempts/0/evidence"
      ]
    }
  ]
}

Run this example in the consoleDownload the request

The lookup finds the label already bought

{
  "decision": "carrier",
  "proposal": {
    "operation": "LabelCreate",
    "key": "CR-0413",
    "digest": "c7e1f0"
  },
  "connector": {
    "carrier": "UPS",
    "idempotency": "unverified",
    "lookup": "verified"
  },
  "requests": [
    {
      "key": "CR-0412",
      "digest": "c7e1f0",
      "operation": "LabelCreate",
      "attempts": [
        {
          "kind": "request",
          "transport": "sent",
          "at": "2026-10-02T14:02:11Z",
          "evidence": "POST /api/shipments/v2409/ship: read timed out after 30000 ms; request body fully written"
        },
        {
          "kind": "lookup",
          "transport": "response_received",
          "http_status": 200,
          "at": "2026-10-02T14:05:40Z",
          "evidence": "{\"shipmentResults\":[{\"customerReference\":\"CR-0412\",\"trackingNumber\":\"1Z9F21470345992311\",\"status\":\"Label Created\",\"createdAt\":\"2026-10-02T14:02:12Z\"}]}"
        }
      ]
    }
  ]
}

Response from the rules with no model loaded, so every question abstains.

{
  "verdict": "reconcile",
  "state": "Uncertain",
  "next": {
    "action": "lookup",
    "text": "Look up request CR-0412 with the carrier and record what it finds before anything billable runs again."
  },
  "questions": [
    {
      "ask": "requests/0/attempts/0",
      "question": "carrier_outcome@1",
      "status": "model_unavailable",
      "evidence": [
        "/requests/0/attempts/0/evidence"
      ]
    },
    {
      "ask": "requests/0/attempts/1",
      "question": "carrier_outcome@1",
      "status": "model_unavailable",
      "evidence": [
        "/requests/0/attempts/1/evidence"
      ]
    }
  ]
}

Run this example in the consoleDownload the request

Call it from your code

Each snippet sends the first example above to the hosted API with the key in RACKSORT_API_KEY and prints the verdict and the next step. Create an account, then create a key. The quickstart walks through the first request.

curl

export RACKSORT_API_KEY="paste-your-key-here"
curl https://racksort.com/api/v1/decide \
  -H "Authorization: Bearer $RACKSORT_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'EOF'
{
  "decision": "carrier",
  "proposal": {
    "operation": "LabelCreate",
    "key": "CR-0413",
    "digest": "c7e1f0"
  },
  "connector": {
    "carrier": "UPS",
    "idempotency": "unverified",
    "lookup": "verified"
  },
  "requests": [
    {
      "key": "CR-0412",
      "digest": "c7e1f0",
      "operation": "LabelCreate",
      "attempts": [
        {
          "kind": "request",
          "transport": "sent",
          "at": "2026-10-02T14:02:11Z",
          "evidence": "POST /api/shipments/v2409/ship: read timed out after 30000 ms; request body fully written"
        }
      ]
    }
  ]
}
EOF

Python

Python 3.8 or newer, standard library only. Keep the User-Agent header: requests with Python's default one are refused. With requests or httpx it is not needed.

import json
import os
import urllib.error
import urllib.request

request = {
    "decision": "carrier",
    "proposal": {
        "operation": "LabelCreate",
        "key": "CR-0413",
        "digest": "c7e1f0",
    },
    "connector": {
        "carrier": "UPS",
        "idempotency": "unverified",
        "lookup": "verified",
    },
    "requests": [
        {
            "key": "CR-0412",
            "digest": "c7e1f0",
            "operation": "LabelCreate",
            "attempts": [
                {
                    "kind": "request",
                    "transport": "sent",
                    "at": "2026-10-02T14:02:11Z",
                    "evidence": "POST /api/shipments/v2409/ship: read timed out after 30000 ms; request body fully written",
                },
            ],
        },
    ],
}

call = urllib.request.Request(
    "https://racksort.com/api/v1/decide",
    data=json.dumps(request).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['RACKSORT_API_KEY']}",
        "Content-Type": "application/json",
        # Cloudflare refuses Python's default User-Agent, so name the client.
        "User-Agent": "racksort-example/1.0",
    },
)
try:
    with urllib.request.urlopen(call, timeout=30) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise SystemExit(json.load(error)["error"]["message"])
print(result["verdict"], "-", result["next"]["text"])

TypeScript

Node.js 18 or newer. Save it as decide.mts and run npx tsx decide.mts.

type Verdict = "allow" | "replay" | "reject" | "review" | "reconcile";
interface Decision {
  verdict: Verdict;
  state?: string;
  next: { action: string; text: string; role?: string };
}

const request = {
  "decision": "carrier",
  "proposal": {
    "operation": "LabelCreate",
    "key": "CR-0413",
    "digest": "c7e1f0"
  },
  "connector": {
    "carrier": "UPS",
    "idempotency": "unverified",
    "lookup": "verified"
  },
  "requests": [
    {
      "key": "CR-0412",
      "digest": "c7e1f0",
      "operation": "LabelCreate",
      "attempts": [
        {
          "kind": "request",
          "transport": "sent",
          "at": "2026-10-02T14:02:11Z",
          "evidence": "POST /api/shipments/v2409/ship: read timed out after 30000 ms; request body fully written"
        }
      ]
    }
  ]
};

const response = await fetch("https://racksort.com/api/v1/decide", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RACKSORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(request),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
const result = body as Decision;
console.log(result.verdict, "-", result.next.text);

Request schema

{
  "type": "object",
  "required": [
    "decision",
    "proposal",
    "connector"
  ],
  "additionalProperties": false,
  "properties": {
    "decision": {
      "const": "carrier"
    },
    "proposal": {
      "type": "object",
      "required": [
        "operation",
        "key",
        "digest"
      ],
      "additionalProperties": false,
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "LabelCreate",
            "LabelVoid",
            "ManifestSubmit",
            "TenderRegister",
            "BOLCreate"
          ]
        },
        "key": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "digest": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "replaces": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "voids": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      }
    },
    "connector": {
      "type": "object",
      "required": [
        "idempotency",
        "lookup"
      ],
      "additionalProperties": false,
      "properties": {
        "carrier": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "idempotency": {
          "type": "string",
          "enum": [
            "verified",
            "unverified",
            "unsupported"
          ]
        },
        "lookup": {
          "type": "string",
          "enum": [
            "verified",
            "none"
          ]
        }
      }
    },
    "requests": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "key",
          "digest",
          "operation",
          "attempts"
        ],
        "additionalProperties": false,
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "digest": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "operation": {
            "type": "string",
            "enum": [
              "LabelCreate",
              "LabelVoid",
              "ManifestSubmit",
              "TenderRegister",
              "BOLCreate"
            ]
          },
          "remote_request_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "voids": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "attempts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "transport"
              ],
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "request",
                    "lookup"
                  ]
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "transport": {
                  "type": "string",
                  "enum": [
                    "not_sent",
                    "sent",
                    "response_received"
                  ]
                },
                "http_status": {
                  "type": "integer",
                  "minimum": 100,
                  "maximum": 599
                },
                "document_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "evidence": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                }
              }
            },
            "maxItems": 50
          }
        }
      },
      "maxItems": 50
    }
  }
}