> ## Documentation Index
> Fetch the complete documentation index at: https://smartcar.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing with Postman

> In this tutorial we'll go over how to use Vehicle Simulator to test out Smartcar using Postman.

## What is Postman?

Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs - faster.
You’ll need a few things to start making API calls with Smartcar and Postman:

* [A Postman Account](https://identity.getpostman.com/signup?continue=https%3A%2F%2Fgo.postman.co%2Fbuild)
* [Smartcar’s Postman Collection](https://www.postman.com/smartcar/smartcar-api/collection/qk7g8v2/smartcar-api-v3?action=share\&creator=33621094)
* [A Smartcar Developer Account](https://dashboard.smartcar.com/signup)

## Configuring the Connect flow in Postman

1. Install the latest [Postman app](https://www.postman.com/downloads/) and log in
2. Import the [Smartcar collection](https://www.postman.com/smartcar/smartcar-api/collection/qk7g8v2/smartcar-api-v3?action=share\&creator=33621094) into your local Postman workspace. Hit Import.
3. Click Link, paste in [the link](https://www.postman.com/smartcar/smartcar-api/collection/qk7g8v2/smartcar-api-v3?action=share\&creator=33621094) to the collection and hit Continue.
4. On the next screen, hit Import.

<Tabs>
  <Tab title="Step 1">
    <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/postman.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=eff974c27c35429e996cc03ac0537ca3" width="1909" height="735" data-path="images/help-center/guide-postman/postman.png" />
  </Tab>

  <Tab title="Step 2">
    <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/import1.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=0d6ca63f2c0ec0531d6f43013d898d46" width="2000" height="781" data-path="images/help-center/guide-postman/import1.png" />
  </Tab>

  <Tab title="Step 3">
    <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/import2.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=ab103641bc93ed9d009e611042a87ddd" width="2000" height="2034" data-path="images/help-center/guide-postman/import2.png" />
  </Tab>

  <Tab title="Step 4">
    <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/import3.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=ca91ea1a83ddcd32189f05e142917e3e" width="2000" height="3103" data-path="images/help-center/guide-postman/import3.png" />
  </Tab>
</Tabs>

## Smartcar Application Configuration

If you haven’t already signed up for a Smartcar Developer account, you can do so from this [**sign-up link**](https://dashboard.smartcar.com/signup).

* Grab your **Client ID** and **Client Secret** from the Configuration page after you sign in, and copy them to someplace secure. You’ll need those tokens a little later in this setup.
* Under **Configuration > Application Details** for your application, you’ll need to add the following Redirect URIs. This will ensure that Smartcar Connect exits successfully with both Postman’s Native and Web clients.

```
https://oauth.pstmn.io/v1/browser-callback 
http://localhost:8000/exchange
```

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/appConfig.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=227ee48bcdd4a1994049717c996deaa4" width="2000" height="1306" data-path="images/help-center/guide-postman/appConfig.png" />
</Frame>

Through the Connect flow, you’re able to get consent from vehicle owners to connect their vehicle to your application. Postman provides an easy way to manage OAuth 2.0 flows under the Authorization tab of a Collection. Set up the Configuration Options for either a live or simulated vehicle.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/authorization.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=44585e961f665d2d259993a8ddd4319e" width="2000" height="2428" data-path="images/help-center/guide-postman/authorization.png" />
</Frame>

**Live Vehicle**

| Parameter        | Description                                                                                                       |
| ---------------- | ----------------------------------------------------------------------------------------------------------------- |
| Auth URL         | `https://connect.smartcar.com/oauth/authorize?approval_prompt=force`                                              |
| Access Token URL | `https://iam.smartcar.com/oauth2/token`                                                                           |
| Client ID        | `client_id` from your Dashboard                                                                                   |
| Client Secret    | `client_secret` from your Dashboard                                                                               |
| Grant Type       | `client_credentials`                                                                                              |
| Scope            | A space-separated list of [permissions](/api-reference/permissions) that your application is requesting access to |

**Simulated Vehicle**

| Parameter        | Description                                                                                                       |
| ---------------- | ----------------------------------------------------------------------------------------------------------------- |
| Auth URL         | `https://connect.smartcar.com/oauth/authorize?approval_prompt=force&mode=simulated`                               |
| Access Token URL | `https://iam.smartcar.com/oauth2/token`                                                                           |
| Client ID        | `client_id` from your Dashboard                                                                                   |
| Client Secret    | `client_secret` from your Dashboard                                                                               |
| Grant Type       | `client_credentials`                                                                                              |
| Scope            | A space-separated list of [permissions](/api-reference/permissions) that your application is requesting access to |

## Setting up a Simulated Vehicle

Under the Simulator tab on Dashboard, hit Add Vehicle. Note that you may already have a pre-created simulated vehicle available, if so skip to **Connecting to a vehicle** below.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/sim1.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=ac48f25d23f26724ac3c3a030a98db67" width="1601" height="633" data-path="images/help-center/guide-postman/sim1.png" />
</Frame>

Select a region and MMY for your vehicle, then hit Search by MMY

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/sim2.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=d4185d0baab4608387e4bcb418395156" width="1691" height="1120" data-path="images/help-center/guide-postman/sim2.png" />
</Frame>

After selecting Use Vehicle, you’ll want to select a state for the vehicle. After that, you’ll get a set of credentials to use in the Connect flow.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/sim3.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=a80ce27d74bf60db8c576a22a73dfe50" width="1691" height="920" data-path="images/help-center/guide-postman/sim3.png" />
</Frame>

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/sim4.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=234f54c381002a8dc4bbb988d9678d23" width="1929" height="849" data-path="images/help-center/guide-postman/sim4.png" />
</Frame>

Before proceeding to the next step, you’ll want to start the simulation in the Smartcar Dashboard.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/sim5.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=62c9900a88d6027f0ef2c623aaf59729" width="1468" height="646" data-path="images/help-center/guide-postman/sim5.png" />
</Frame>

## Connecting to a vehicle

If configured correctly, when you click **Get New Access Token** in Postman, you should see the first screen of the Connect flow.

<Tip>
  Before hitting Continue, make sure to select a country from the dropdown appropriate to the region you selected for your simulated vehicle.
</Tip>

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/connect1.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=4eac302ec3adec5e4bd844218b1e8c02" width="2000" height="2490" data-path="images/help-center/guide-postman/connect1.png" />
</Frame>

Continue through the Connect flow, select the brand of your simulated vehicle and enter in the credentials you were issued for your simulated vehicle.
After accepting the permissions you’ll be met with the following screen:

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/connect2.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=b3fda47b60fb4b1d049769362b24b9fa" width="2000" height="1171" data-path="images/help-center/guide-postman/connect2.png" />
</Frame>

Hit Use Token. You should see Access Token under Current Token populate with the access\_token from the popup. Using this access\_token you can make API requests to Smartcar's API.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/connect3.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=71eef9cb9f7fffbe7015cb6110b6daa7" width="2000" height="774" data-path="images/help-center/guide-postman/connect3.png" />
</Frame>

<br />

<Warning>
  Access tokens are valid for **1 hour**. When the token expires, request a new one from the [token endpoint](/api-reference/authorization/request-access-token) using the Client Credentials flow. There is no refresh token.
</Warning>

## Making an API request

<Tip>
  Thanks to Postman, requests in the collection will inherit the `access_token` from the OAuth 2.0 Authorization flow we went through in the steps above.
</Tip>

In order to make API requests, we’ll need to first get a Smartcar `vehicle Id`. A `vehicle Id` is a unique identifier for a vehicle on Smartcar’s platform.

This can be done with the `All Vehicles` request. Making this request will assign the `vehicle Id` to the `{{vehicle_id}}` variable for other requests in the Collection.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/req1.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=1182006af59ffca20f826b396d7876c5" width="2000" height="1186" data-path="images/help-center/guide-postman/req1.png" />
</Frame>

<br />

Now that you've got a vehicle Id, you can make a request to other endpoints. Hitting Vehicle Info, we can see the MMY of the vehicle.

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/req2.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=c9b1d9dd016d9ef9674a84a368648db6" width="2000" height="1105" data-path="images/help-center/guide-postman/req2.png" />
</Frame>

<br />

Checking `EV Battery Level`, we can see the response matches the vehicle state on the simulator

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/klvdxjd2EpHsqsG2/images/help-center/guide-postman/req3.png?fit=max&auto=format&n=klvdxjd2EpHsqsG2&q=85&s=7230503ce005f2bde54dddfd00c5b58c" width="2000" height="1036" data-path="images/help-center/guide-postman/req3.png" />
</Frame>

<br />

<Frame type="simple">
  <img src="https://mintcdn.com/smartcar-docs/bl2aLGyZU43A919o/images/help-center/guide-postman/req4.png?fit=max&auto=format&n=bl2aLGyZU43A919o&q=85&s=5798556122aea8b0f4e20aa60d816b7e" width="2000" height="1580" data-path="images/help-center/guide-postman/req4.png" />
</Frame>

<br />

## Troubleshooting

<AccordionGroup>
  <Accordion title="I’m getting an Invalid Credentials error in the Connect flow">
    * Check that you’re launching Connect in simulated mode
    * If you’re still running into an error make sure you’ve selected a country that matches the region you selected for your simulated vehicle.
  </Accordion>

  <Accordion title="I’m getting a 403 - Permission error on API requests">
    * Check that the vehicle you’ve created supports the endpoint. Select View Estimated Latencies to see a list of endpoints supported for the vehicle.
    * If you’re still running into the error, check that you’ve requested the appropriate permission in the scope parameter of the Connect URL.

    <Tip>
      You can always check the `/permissions` endpoint to see what endpoints you have access to.
    </Tip>
  </Accordion>
</AccordionGroup>
