data
AfterShip Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the AfterShip KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.aftership.*.
Use lua_read_doc("integrations.aftership") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
AfterShip workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.aftership.list_trackings({}))' --json kosmo integrations:lua --eval 'print(docs.read("aftership"))' --json
kosmo integrations:lua --eval 'print(docs.read("aftership.list_trackings"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local aftership = app.integrations.aftership
local result = aftership.list_trackings({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.aftership, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.aftership.default.* or app.integrations.aftership.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need AfterShip, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
AfterShip
Namespace: aftership
Use this integration to manage AfterShip Tracking API records, detect couriers, work with courier connections, and request estimated delivery date predictions.
Authentication
AfterShip requires api_key. The integration sends it as the as-api-key
header and uses the versioned Tracking API base path.
Tools
- Trackings:
aftership_list_trackings,aftership_create_tracking,aftership_get_tracking,aftership_update_tracking,aftership_delete_tracking,aftership_retrack_tracking,aftership_mark_tracking_completed. - Couriers:
aftership_list_couriers,aftership_detect_courier. - Courier connections:
aftership_list_courier_connections,aftership_create_courier_connections,aftership_get_courier_connection,aftership_update_courier_connection,aftership_delete_courier_connection. - Estimated delivery date:
aftership_predict_estimated_delivery_date,aftership_batch_predict_estimated_delivery_date.
Return Notes
Responses keep AfterShip’s upstream envelope and field names. Do not include real customer emails, phone numbers, addresses, order IDs, or tracking numbers in tests, fixtures, or public docs.
For create/update tracking tools, you may pass either a full tracking object
or top-level fields such as tracking_number, slug, title, and
destination_country_region; the integration wraps top-level fields in the
AfterShip tracking envelope.
Examples
local created = tools.aftership_create_tracking({
tracking_number = "TEST123456789",
slug = "usps",
title = "Order TEST-1001",
destination_country_region = "USA"
})
local couriers = tools.aftership_detect_courier({
tracking_number = "TEST123456789",
destination_country_region = "USA"
})
local active = tools.aftership_list_trackings({
delivery_status = "InTransit",
limit = 20
})Raw agent markdown
# AfterShip
Namespace: `aftership`
Use this integration to manage AfterShip Tracking API records, detect couriers,
work with courier connections, and request estimated delivery date predictions.
## Authentication
AfterShip requires `api_key`. The integration sends it as the `as-api-key`
header and uses the versioned Tracking API base path.
## Tools
- Trackings: `aftership_list_trackings`, `aftership_create_tracking`,
`aftership_get_tracking`, `aftership_update_tracking`,
`aftership_delete_tracking`, `aftership_retrack_tracking`,
`aftership_mark_tracking_completed`.
- Couriers: `aftership_list_couriers`, `aftership_detect_courier`.
- Courier connections: `aftership_list_courier_connections`,
`aftership_create_courier_connections`, `aftership_get_courier_connection`,
`aftership_update_courier_connection`,
`aftership_delete_courier_connection`.
- Estimated delivery date: `aftership_predict_estimated_delivery_date`,
`aftership_batch_predict_estimated_delivery_date`.
## Return Notes
Responses keep AfterShip's upstream envelope and field names. Do not include
real customer emails, phone numbers, addresses, order IDs, or tracking numbers
in tests, fixtures, or public docs.
For create/update tracking tools, you may pass either a full `tracking` object
or top-level fields such as `tracking_number`, `slug`, `title`, and
`destination_country_region`; the integration wraps top-level fields in the
AfterShip `tracking` envelope.
## Examples
```lua
local created = tools.aftership_create_tracking({
tracking_number = "TEST123456789",
slug = "usps",
title = "Order TEST-1001",
destination_country_region = "USA"
})
local couriers = tools.aftership_detect_courier({
tracking_number = "TEST123456789",
destination_country_region = "USA"
})
local active = tools.aftership_list_trackings({
delivery_status = "InTransit",
limit = 20
})
``` local result = app.integrations.aftership.list_trackings({})
print(result) Functions
list_trackings Read
List shipment trackings with filters and pagination.
- Lua path
app.integrations.aftership.list_trackings- Full name
aftership.aftership_list_trackings
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_tracking Write
Create a shipment tracking.
- Lua path
app.integrations.aftership.create_tracking- Full name
aftership.aftership_create_tracking
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_tracking Read
Get a tracking by ID.
- Lua path
app.integrations.aftership.get_tracking- Full name
aftership.aftership_get_tracking
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_tracking Write
Update a tracking by ID.
- Lua path
app.integrations.aftership.update_tracking- Full name
aftership.aftership_update_tracking
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_tracking Write
Delete a tracking by ID.
- Lua path
app.integrations.aftership.delete_tracking- Full name
aftership.aftership_delete_tracking
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
retrack_tracking Write
Retrack an expired tracking by ID.
- Lua path
app.integrations.aftership.retrack_tracking- Full name
aftership.aftership_retrack_tracking
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
mark_tracking_completed Write
Mark a tracking as completed by ID.
- Lua path
app.integrations.aftership.mark_tracking_completed- Full name
aftership.aftership_mark_tracking_completed
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_couriers Read
List supported couriers.
- Lua path
app.integrations.aftership.list_couriers- Full name
aftership.aftership_list_couriers
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
detect_courier Read
Detect courier candidates for a tracking number.
- Lua path
app.integrations.aftership.detect_courier- Full name
aftership.aftership_detect_courier
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_courier_connections Read
List courier connections.
- Lua path
app.integrations.aftership.list_courier_connections- Full name
aftership.aftership_list_courier_connections
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_courier_connections Write
Create courier connections.
- Lua path
app.integrations.aftership.create_courier_connections- Full name
aftership.aftership_create_courier_connections
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_courier_connection Read
Get a courier connection by ID.
- Lua path
app.integrations.aftership.get_courier_connection- Full name
aftership.aftership_get_courier_connection
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_courier_connection Write
Update a courier connection by ID.
- Lua path
app.integrations.aftership.update_courier_connection- Full name
aftership.aftership_update_courier_connection
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_courier_connection Write
Delete a courier connection by ID.
- Lua path
app.integrations.aftership.delete_courier_connection- Full name
aftership.aftership_delete_courier_connection
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
predict_edd Read
Predict estimated delivery date for one shipment.
- Lua path
app.integrations.aftership.predict_edd- Full name
aftership.aftership_predict_estimated_delivery_date
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
batch_predict_edd Read
Predict estimated delivery dates for multiple shipments.
- Lua path
app.integrations.aftership.batch_predict_edd- Full name
aftership.aftership_batch_predict_estimated_delivery_date
| Parameter | Type | Required | Description |
|---|---|---|---|
shipments | array | no | Batch shipment prediction payload. |
raw | object | no | Full batch prediction payload. |