# Create destination

# Create destination

## Body parameters

| Name     | Type   | Description                                                                                                                                                                                                                                                                                           |
| :------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| address  | object | The destination’s street address details.                                                                                                                                                                                                                                                             |
| location | array  | Optional. The `[ longitude, latitude ]` geographic coordinates. If missing, the API will geocode based on the address details provided. Note that geocoding may slightly modify the format of the `address` properties. `address.unparsed` cannot be provided if you are also including a `location`. |
| notes    | string | Optional. Notes about the destination.                                                                                                                                                                                                                                                                |
| options  | object | Optional. Includes the `language` options.                                                                                                                                                                                                                                                            |

### Address parameters

An `address` has the following properties:

| Name       | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                              |
| :--------- | :----- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name       | string | Optional. A name associated with this address, for example, *"Transamerica Pyramid"*.                                                                                                                                                                                                                                                                                                                                    |
| number     | string | Required. The number component of this address, it may also contain letters.                                                                                                                                                                                                                                                                                                                                             |
| street     | string | Required. The name of the street.                                                                                                                                                                                                                                                                                                                                                                                        |
| apartment  | string | Optional. The suite or apartment number, or any additional relevant information.                                                                                                                                                                                                                                                                                                                                         |
| city       | string | Required. The name of the municipality.                                                                                                                                                                                                                                                                                                                                                                                  |
| state      | string | Optional. The name of the state, province or jurisdiction.                                                                                                                                                                                                                                                                                                                                                               |
| postalCode | string | Optional. The postal or zip code.                                                                                                                                                                                                                                                                                                                                                                                        |
| country    | string | Required. The name of the country.                                                                                                                                                                                                                                                                                                                                                                                       |
| unparsed   | string | Optional. A complete address specified in a single, unparsed string where the various elements are separated by commas. If present, all other address properties will be ignored (with the exception of `name` and `apartment`). In some countries, you may skip most address details (like `city` or `state`) if you provide a valid `postalCode`: for example, `543 Howard St, 94105, USA` will be geocoded correctly. |

An `options` has the following properties:

| Name     | Type   | Description                                                                                                                    |
| :------- | :----- | :----------------------------------------------------------------------------------------------------------------------------- |
| language | string | Optional. The language options follows the [ISO Standard](https://en.wikipedia.org/wiki/ISO_3166-1) of 2-letters country code. |

Create destination with complete `address` details, `parsed`, see examples of creating destinations with parsed addresses in the side bar:

```shell Request
curl -X POST "https://onfleet.com/api/v2/destinations" \
       -u "<your_onfleet_api_key>:" \
       -d '{"address":{"number":"543","street":"Howard St","apartment":"5th Floor","city":"San Francisco","state":"CA","country":"USA"},"notes":"Don\'t forget to check out the epic rooftop."}'
```

```python
onfleet.destinations.create(body={
  "address":{
    "number":"543",
    "street":"Howard St",
    "apartment":"5th Floor",
    "city":"San Francisco",
    "state":"CA",
    "country":"USA"},
  "notes":"Don\'t forget to check out the epic rooftop."
})
```

```javascript
onfleet.destinations.create({
  "address":{
    "number":"543",
    "street":"Howard St",
    "apartment":"5th Floor",
    "city":"San Francisco",
    "state":"CA","country":"USA"},
  "notes":"Don\'t forget to check out the epic rooftop."
});
```

```php
$onfleet->destinations->create([
  "address" => [
    "number" => "543",
    "street" => "Howard St",
    "apartment" => "5th Floor",
    "city" => "San Francisco",
    "state" => "CA","country" => "USA"
  ],
  "notes" => "Don\'t forget to check out the epic rooftop."
])
```

```json Response
{
  "id": "JLn6ZoYGZWn2wB2HaR9glsqB",
  "timeCreated": 1455156663000,
  "timeLastModified": 1455156663896,
  "location": [
    -122.3965731,
    37.7875728
  ],
  "address": {
    "apartment": "5th Floor",
    "state": "California",
    "postalCode": "94105",
    "country": "United States",
    "city": "San Francisco",
    "street": "Howard Street",
    "number": "543"
  },
  "notes": "Don't forget to check out the epic rooftop.",
  "metadata": []
}
```

Create destination using an `unparsed` address, see examples of unparsed addresses in the side bar:

```shell Request
curl -X POST "https://onfleet.com/api/v2/destinations" \
       -u "cd3b3de84cc1ee040bf06512d233719c:" \
       -d '{"address":{"unparsed":"666 Post St, SF, CA, USA"}}'
```

```python
onfleet.destinations.create(body={"address":{"unparsed":"666 Post St, SF, CA, USA"}})
```

```javascript
onfleet.destinations.create({"address":{"unparsed":"666 Post St, SF, CA, USA"}});
```

```json Response
{
  "id": "barP8D82zGyzd~7~74dSCDV1",
  "timeCreated": 1455156664000,
  "timeLastModified": 1455156664297,
  "location": [
    -122.4128901,
    37.787933
  ],
  "address": {
    "apartment": "",
    "state": "California",
    "postalCode": "94109",
    "country": "United States",
    "city": "San Francisco",
    "street": "Post Street",
    "number": "666"
  },
  "notes": "",
  "metadata": []
}
```

Create destination with `location` coordinates must include parsed `address.city` and `address.country` components at the minimum.  See examples of locations addresses in the side bar:

```shell Location Coordinates with Parsed address Request
curl -X POST "https://onfleet.com/api/v2/destinations" \
       -u "cd3b3de84cc1ee040bf06512d233719c:" \
       -d '{"location": [-122.3966546,37.7875914],"address": {"apartment": "5th Floor","state": "California","postalCode": "94105","number": "543","street": "Howard Street","city": "San Francisco","country": "United States"}}'
```

```json Location Coordinates with Parsed address Response
{
    "id": "d*LRNTCgQSmBzj~pxW1eBsLq",
    "timeCreated": 1621459229000,
    "timeLastModified": 1621459229693,
    "location": [
        -122.3966546,
        37.7875914
    ],
    "address": {
        "apartment": "5th Floor",
        "state": "California",
        "postalCode": "94105",
        "number": "543",
        "street": "Howard Street",
        "city": "San Francisco",
        "country": "United States"
    },
    "notes": "",
    "metadata": [],
    "googlePlaceId": null,
    "warnings": []
}
```