# Create Task (Template Use) — Onfleet

> Creates a single task. Used for simple templates only. See the docs here

- Key: `onfleet-create-task-template`
- 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-task-template
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/onfleet/actions/create-task-template/create-task-template.ts

## Description

Creates a single task. Used for simple templates only. [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. |
| `recipientName` | `string` | Yes | The person to be notified that the dropoff is occurring. |
| `recipientPhone` | `string` | Yes | The phone of the recipient. |
| `recipientNotes` | `string` | No | Notes related the recipient or the destination like door codes, beware of dog, etc. |
| `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. |
| `notes` | `string` | No | Notes for the task. Field length cannot exceed 10,000 characters. |
| `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. |
| `pickupTask` | `boolean` | No | Whether the task is a pickup task. |
| `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. |

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

---

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