# Create Tracking — AfterShip

> Creates a tracking. See the documentation

- Key: `aftership-create-tracking`
- Type: Action (Write)
- Version: 0.1.1
- App: AfterShip (`aftership`) — https://pipedream.com/apps/aftership.md
- This page (HTML): https://pipedream.com/apps/aftership/actions/create-tracking
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/aftership/actions/create-tracking/create-tracking.mjs

## Description

Creates a tracking. [See the documentation](https://www.aftership.com/docs/api/4/trackings/post-trackings)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `trackingNumber` | `string` | Yes | The tracking number of the shipment. |
| `slug` | `string` | No | The unique code of the courier. Get courier codes here. |
| `title` | `string` | No | By default this field shows the tracking_number, but you can customize it as you wish with any info (e.g. the order number). |
| `smses` | `string[]` | No | The phone number(s) to receive sms notifications. Enter + andarea code before phone number. Accept either array or comma separated as input. Supports up to 3 phone numbers. |
| `emails` | `string[]` | No | Email address(es) to receive email notifications. Accept either array or comma separated as input. Supports up to 3 email addresses. |
| `customerName` | `string` | No | Customer name of the tracking. |
| `orderId` | `string` | No | A globally-unique identifier for the order. |
| `orderIdPath` | `string` | No | The URL for the order in your system or store. |
| `customFields` | `object` | No | Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any personal data in custom fields. |
| `orderNumber` | `string` | No | A unique, human-readable identifier for the order. |
| `language` | `string` | No | The recipient’s language. If you set up AfterShip notifications in different languages, we use this to send the recipient tracking updates in their preferred language. |
| `orderPromisedDeliveryDate` | `string` | No | The promised delivery date of the order. It uses the format YYYY-MM-DD. |
| `deliveryType` | `string` | No | Shipment delivery type. |
| `pickupLocation` | `string` | No | Shipment pickup location for receiver. |
| `pickupNote` | `string` | No | Shipment pickup note for receiver. |
| `trackingAccountNumber` | `string` | No | The shipper's carrier account number. Refer to this article on additional tracking fields for more details. |
| `trackingKey` | `string` | No | A type of tracking credential required by some carriers. Refer to this article on additional tracking fields for more details. |
| `trackingShipDate` | `string` | No | The date the shipment was sent, using the format YYYYMMDD. Refer to this article on additional tracking fields for more details. |
| `originCountryIso3` | `string` | No | The ISO Alpha-3 code (3 letters) for the origin country/region. E.g. USA for the United States. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `originState` | `string` | No | The state of the sender's address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `originCity` | `string` | No | The city of the sender's address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `originPostalCode` | `string` | No | The postal of the sender's address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `originRawLocation` | `string` | No | The sender address that the shipment is shipping from. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `destinationCountryIso3` | `string` | No | The ISO Alpha-3 code (3 letters) for the destination country/region. E.g. USA for the United States. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `destinationState` | `string` | No | The state of the recipient's address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `destinationCity` | `string` | No | The city of the recipient's address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. |
| `note` | `string` | No | Text field for the note. |
| `orderDate` | `string` | No | Order date in YYYY-MM-DDTHH:mm:ssZ format. e.g. 2021-07-26T11:23:51-05:00 |
| `shipmentType` | `string` | No | The carrier service type for the shipment. If you provide info for this field, AfterShip will not update it with info from the carrier. |
| `shipmentTags` | `string[]` | No | Used to add tags to your shipments to help categorize and filter them easily. Max 50 items. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "aftership",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "aftership-create-tracking",
  arguments: {
    trackingNumber: "Tracking Number",
    slug: "Slug",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "aftership-create-tracking",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    aftership: { authProvisionId: "apn_xxxxxxx" },
    trackingNumber: "Tracking Number",
    slug: "Slug",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "aftership-create-tracking",
    "configured_props": {
      "aftership": { "authProvisionId": "apn_xxxxxxx" },
      "trackingNumber": "Tracking Number",
      "slug": "Slug"
    }
  }'
```

---

- App: https://pipedream.com/apps/aftership.md · All apps: https://pipedream.com/apps
