# Create Linked Pickup & Dropoff Tasks — Onfleet

> Create a pickup task and dropoff task linked with each other. See the docs here

- Key: `onfleet-create-pickup-dropoff-task`
- Type: Action (Write)
- Version: 0.0.2
- App: Onfleet (`onfleet`) — https://pipedream.com/apps/onfleet.md
- This page (HTML): https://pipedream.com/apps/onfleet/actions/create-pickup-dropoff-task
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/onfleet/actions/create-pickup-dropoff-task/create-pickup-dropoff-task.ts

## Description

Create a pickup task and dropoff task linked with each other. [See the docs here](https://docs.onfleet.com/reference/create-task)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `merchant` | `string` | Yes | The ID of the organization that will be displayed to the recipient of the task. Defaults to the creating organization. If you perform deliveries on behalf of a connected organization and want to display their name, logo, and branded notifications, provide their organization ID. Options are loaded from the connected account. |
| `executor` | `string` | Yes | The ID of the organization that will be responsible for fulfilling the task. Defaults to the creating organization. If you delegate your deliveries to a third party, provide their organization ID. Options are loaded from the connected account. |
| `hasPickupRecipient` | `boolean` | Yes | If the pickup have a recipient who should be notified of task status changes. |
| `hasDropoffRecipient` | `boolean` | Yes | If the dropoff have a recipient who should be notified of task status changes. |
| `latitude` | `string` | No | The Latitude of the destination. |
| `longitude` | `string` | No | The Longitude of the destination. |
| `street` | `string` | Yes | If coordinates used, this will be for display purposes only. Coordinates will be relied on for actual location. Used for the number and name of the street. |
| `apartment` | `string` | No | For display purposes only. Used for Apartment, suite or other descriptive information. |
| `city` | `string` | Yes | If coordinates used, for display purposes only. Coordinates will be relied on for actual location. |
| `state` | `string` | Yes | If coordinates used, for display purposes only. Coordinates will be relied on for actual location. |
| `postalCode` | `string` | Yes | If coordinates used, for display purposes only. Coordinates will be relied on for actual location. |
| `country` | `string` | Yes | If coordinates used, for display purposes only. Coordinates will be relied on for actual location. |
| `taskLinkOrder` | `integer` | Yes | The order in which to create the linked task relationship. By default, the pickup is created as the prerequisite to the dropoff. Choose "Dropoff first" to reverse this order, requiring completion of the dropoff before the pickup. |
| `autoAssign` | `string` | Yes | Assignment type |
| `quantity` | `integer` | No | The number of units to be dropped off while completing this task, for route optimization purposes. |
| `serviceTime` | `integer` | No | The number of minutes to be spent by the worker on arrival at this task's destination, for route optimization purposes. |
| `signatureRequirement` | `boolean` | Yes | A signature must be collected to complete this task. |
| `photoRequirement` | `boolean` | Yes | A photo must be collected to complete this task. |
| `notesRequirement` | `boolean` | Yes | Task completion notes must be submitted to complete this task. |
| `minimumAgeRequirement` | `integer` | No | The recipient's ID must be scanned and their age verified to be greater than or equal to the minimumAge in order to complete the task. Must be in a plan that supports ID verification. |
| `completeAfter` | `integer` | No | A timestamp in unix time for the earliest time the task should be completed, in milliseconds precision. |
| `completeBefore` | `integer` | No | A timestamp in unix time for the latest time the task should be completed, in milliseconds precision. |
| `notes` | `string` | No | Notes for the task. Field length cannot exceed 10,000 characters. |
| `appearance` | `object` | No | Set triangle colored pins on the map. |

## 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": "onfleet",
      },
    },
  },
)

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: "onfleet-create-pickup-dropoff-task",
  arguments: {
    merchant: "Merchant",
    executor: "Executor",
  },
})
```

**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: "onfleet-create-pickup-dropoff-task",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    onfleet: { authProvisionId: "apn_xxxxxxx" },
    merchant: "Merchant",
    executor: "Executor",
  },
})

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": "onfleet-create-pickup-dropoff-task",
    "configured_props": {
      "onfleet": { "authProvisionId": "apn_xxxxxxx" },
      "merchant": "Merchant",
      "executor": "Executor"
    }
  }'
```

---

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