---
agentTools:
  projectIndex: https://developer-docs.gomotive.com/llms.txt
---

# Subscribe to the location of a vehicle or an asset

**Purpose**: Use this API to subscribe to the location of a vehicle or an asset. When you subscribe to the location of an asset or a vehicle, you are essentially tracking the location of that object. You must specify how long you want to subscribe to the location or in other words, how long you want to track the location. This is determined by the `start_time` and the `end_time` parameters.

> 👍 IMPORTANT
>
> When you are using this endpoint, you must remember the following points:
>
> 1. If you are subscribing the location of vehicle, follow these requirements:
>    1. Vehicle must be owned by a company.
>    2. Vehicle status must be '**active**', and not '**deactivated**'.
> 2. This endpoint does not allow overlapping of tracking instances.
> 3. If you are subscribing the location of an asset, follow these requirements:
>    1. Asset status must be '**active**', and not '**deactivated**'.
>    2. Every asset must have an asset gateway assigned to it.
> 4. The query parameter `start_time`, must be less than 2 weeks from the current date.
> 5. The minimum difference between the `start_time` and `end_time` must be **1 hour.**
> 6. The maximum difference between the `start_time` and the `end_time` must be **5 days**.

```ruby Ruby (OAuth 2.0)
require 'uri'
require 'net/http'

url = URI('https://api.gomotive.com/v1/freight_visibility/subscribe')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request['Authorization'] = "Bearer <OAUTH_TOKEN>"

response = http.request(request)
puts response.read_body
```

## Response Parameters

### tracking\_subscription\_id

* **Type**: Integer
* **Description**: Denotes the ID for tracking the location of the asset or the vehicle.

***

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Motive",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.gomotive.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/freight_visibility/subscribe": {
      "post": {
        "summary": "Subscribe to the location of a vehicle or an asset",
        "description": "",
        "operationId": "subscribe-to-the-location-of-a-vehicle-or-an-asset",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Specify the ID of the company to which the vehicle or the asset belongs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dot_id",
            "in": "query",
            "description": "You must specify the DOT ID, if you not have the Company ID. Otherwise, it is not required.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "asset_id",
            "in": "query",
            "description": "Specify the ID of the asset that you want to track.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vehicle_id",
            "in": "query",
            "description": "Specify the ID of the vehicle to be tracked.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vehicle_name",
            "in": "query",
            "description": "Specify the name of the vehicle that you want to track.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "driver_id",
            "in": "query",
            "description": "Specify the ID of the driver whose vehicle location you are subscribing to.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start_time",
            "in": "query",
            "description": "Provide the start time from when you want to subscribe to a vehicle's location.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "description": "Provide the end time till when you want to subscribe to the vehicle's location.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "load_id",
            "in": "query",
            "description": "Specify the ID of the load. Passed in by client for client side tracking. Sent back to client in response payload containing location.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "load_details",
            "in": "query",
            "description": "Specify the details of the load. Passed in by client for client side tracking. Sent back to client in response payload containing location.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "initial_stop",
            "in": "query",
            "description": "Specify the coordinates of the starting point of load. This is mostly used for client side tracking.",
            "schema": {
              "properties": {
                "lat": {
                  "type": "number",
                  "description": "Specify the latitude coordinates of the initial load point.",
                  "format": "float"
                },
                "lon": {
                  "type": "number",
                  "description": "Specify the longitude coordinates of the initial load point.",
                  "format": "float"
                }
              },
              "type": "object"
            }
          },
          {
            "name": "final_stop",
            "in": "query",
            "description": "Specify the final drop off point of the vehicle. This is mostly for the tracking purposes of the client.",
            "schema": {
              "properties": {
                "lat": {
                  "type": "number",
                  "description": "Specify the latitude coordinates of the final drop point.",
                  "format": "float"
                },
                "lon": {
                  "type": "number",
                  "description": "Specify the longitude coordinates of the final drop point.",
                  "format": "float"
                }
              },
              "type": "object"
            }
          },
          {
            "name": "total_distance",
            "in": "query",
            "description": "The total distance covered from the initial load point to drop off point.",
            "schema": {
              "properties": {
                "value": {
                  "type": "number",
                  "description": "Passed in by client for client side tracking. Sent back to client in response payload containing location.",
                  "format": "float"
                },
                "unit": {
                  "type": "string",
                  "description": "[“km”, “mi”] Passed in by client for client side tracking. Sent back to client in response payload containing location."
                }
              },
              "type": "object"
            }
          },
          {
            "name": "trailer_id",
            "in": "query",
            "description": "Specify the ID of the trailer.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "broker_name",
            "in": "query",
            "description": "The name of the freight broker who is tracking the load.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Subscribe to the location of the vehicle or the asset. ": {
                    "value": "  {\n  \"data\": {\n    \"tracking_subscription_id\": 1426\n  }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "tracking_subscription_id": {
                          "type": "integer",
                          "example": 1426,
                          "default": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Invalid tracking time window": {
                    "value": "{\n  \"error_message\": \"tracking time window cannot be less than 1 hour or greater than 5 days\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "tracking time window cannot be less than 1 hour or greater than 5 days"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "403",
            "content": {
              "application/json": {
                "examples": {
                  "Permissions issue": {
                    "value": "{\n  \"error_message\": \"insufficient permissions\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "insufficient permissions"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "66acf64a829e88001980fbf2:66d9ece12bf1860013cdf467"
}
```