---
updatedAt: 2026-04-20T23:54:34.000Z
agentTools:
  projectIndex: https://docs.onfleet.com/llms.txt
---

# Clone task

Create a new task with the same details of an existing task.

## Clone task

The property `sourceTaskId` can be used to keep track of the source task from which the task was cloned. The clone API endpoint takes a single optional parameter on the request body called `options`.

| Name    | Type   | Description                                                                                              |
| :------ | :----- | :------------------------------------------------------------------------------------------------------- |
| options | object | This object allows you to modify the behavior of the cloning function. See the allowed properties below. |

The available fields within the `options` parameter are defined in the below table.

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        includeMetadata
      </td>

      <td>
        boolean
      </td>

      <td>
        If true, metadata will be included on the cloned task.
      </td>
    </tr>

    <tr>
      <td>
        includeBarcodes
      </td>

      <td>
        boolean
      </td>

      <td>
        If true, bar codes will be included on the cloned task.
      </td>
    </tr>

    <tr>
      <td>
        includeDependencies
      </td>

      <td>
        boolean
      </td>

      <td>
        If true, the dependencies will be included on the cloned task.
      </td>
    </tr>

    <tr>
      <td>
        overrides
      </td>

      <td>
        object
      </td>

      <td>
        This object allows you to override certain values on the cloned task. The available fields to override are:

        destination: A destination id or object.

        recipients: An array of recipient objects or an array of recipient ids.

        notes: A string which holds notes for the cloned task

        pickupTask: A boolean which will mark the task as a pick up or drop off task

        serviceTime: A number which indicates the service time

        metadata: An array of metadata objects

        completeAfter: A timestamp which must be in the future

        completeBefore: A timestamp which must be in the future and after the completeAfter if defined.
      </td>
    </tr>
  </tbody>
</Table>

```shell Request
curl -X POST "https://onfleet.com/api/v2/tasks/uO2vKr07h6zg7Fzf~2NC3KLg/clone" \
     -u "<your_api_key>:"
```
```python
onfleet.tasks.clone(id="uO2vKr07h6zg7Fzf~2NC3KLg")
```
```javascript
onfleet.tasks.clone("uO2vKr07h6zg7Fzf~2NC3KLg");
```
```php
$onfleet->tasks->clone("uO2vKr07h6zg7Fzf~2NC3KLg")
```

```json Response
{
  "id": "fesYPEu2FWvubaq~2nof*lCA",
  "timeCreated": 1489010058000,
  "timeLastModified": 1489010058477,
  "organization": "yAM*fDkztrT3gUcz9mNDgNOL",
  "shortId": "9b4zd53d",
  "trackingURL": "https://onf.lt/9b4zd53d",
  "worker": null,
  "merchant": "yAM*fDkztrT3gUcz9mNDgNOL",
  "executor": "yAM*fDkztrT3gUcz9mNDgNOL",
  "creator": "EJmsbJgHiRLPjNVE7GEIPs7*",
  "dependencies": [],
  "state": 0,
  "completeAfter": null,
  "completeBefore": null,
  "pickupTask": false,
  "notes": "",
  "completionDetails": {
    "events": [],
    "failureReason": "NONE",
    "time": null
  },
  "feedback": [],
  "metadata": [],
  "overrides": {},
  "quantity": 0,
  "serviceTime": 0,
  "delayTime": null,
  "sourceTaskId": "uO2vKr07h6zg7Fzf~2NC3KLg",
  "container": {
    "type": "ORGANIZATION",
    "organization": "yAM*fDkztrT3gUcz9mNDgNOL"
  },
  "recipients": [],
  "destination": {
    "id": "Fa0Oxd21cL3T36qw5mGOvZw6",
    "timeCreated": 1485469374000,
    "timeLastModified": 1485469374734,
    "location": [
      -122.43232727050781,
      37.79811961477822
    ],
    "address": {
      "apartment": "",
      "state": "California",
      "postalCode": "94123",
      "country": "United States",
      "city": "San Francisco",
      "street": "Buchanan Street",
      "number": "3020"
    },
    "notes": "",
    "metadata": []
  }
}
```