Enode Developers

Getting started

The Enode API lets you connect to a wide range of green energy hardware. This guide demonstrates linking devices to a user and making your first API call by fetching the user.

Copy linkPrerequisites

Copy linkFetching mocked or real devices

You have one set of credentials for the sandbox environment and one for the production environment. Before making any requests, decide whether to fetch mocked or real devices.

  • For mocked or simulated devices, use the sandbox environment
  • For real devices, use the production environment

The rest of this guide refers to the sandbox environment. For real devices, replace sandbox with production in URLs. Ensure your client_id and client_secret correspond to the chosen environment.

Copy linkCreate a simulated asset in sandbox

In sandbox, you must first create a simulated asset that represents a device you can link.

  1. Open your client in the dashboard and select Simulated assets
  2. Click Create new, and enter any name and select any model
  3. Note the Username and Password of the new device. Use these values in the next step.

Copy linkStep 1: Get an API access token

First, call the Enode OAuth API using client_id and client_secret.

This guide uses cURL for examples, but you can use Postman. To get your access token in Postman, apply these settings. We also maintain an updated Postman collection.

Sample

curl https://oauth.sandbox.enode.io/oauth2/token \
-X POST \
-u {YOUR_CLIENT_ID}:{YOUR_CLIENT_SECRET} \
-d "grant_type=client_credentials"

If you provided the correct values, you should receive a successful response containing an access_token.

Sample

{
  "access_token": "{YOUR_ACCESS_TOKEN}",
  "expires_in": 3599,
  "scope": "",
  "token_type": "bearer"
}

Next, use the access_token to create a Link sessionAPI. This grants the user temporary access to Enode Link UI, a web interface for connecting hardware to your app.

Sample

curl https://enode-api.sandbox.enode.io/users/1ab23cd4/link \
-X POST \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
  "vendorType": "vehicle",
  "scopes": [
    "vehicle:read:data",
    "vehicle:read:location",
    "vehicle:control:charging"
  ],
  "language": "en-US",
  "redirectUri": "https://localhost:3000"
}'

The userId in the call, such as 1ab23cd4, should be a unique string that identifies your user, preferably your user's primary key in your system. The API will automatically create a user if it doesn't recognize the userId. Refer to our API referenceAPI for more details.

A valid access_token results in a successful response with a linkUrl.

Link response

{
  "linkToken": "WFiMjNjZDRANThlZmIyMzMtYTNjNS00Njk...", // Used by the Link SDK
  "linkUrl": "{YOUR_LINK_URL}" // Redirect or display in in-app browser
}

Please note that this API call requires an API version of 2024-01-01 or higher. If you are following this guide using a client created before January 1st 2024, please set a version header or change your default client version. For more information, you can refer to our versioning guideAPI.

Open the linkUrl from the previous step in your browser.

  • If you are using Sandbox 2.0 and created a simulated asset earlier, be sure to choose the vehicle brand of the asset you created and use the username and password provided to you. You may use any two-factor authentication code.
  • If you are using legacy Sandbox, you can use any combination of email, password, and two-factor authentication code, as in the example below.

Proceed to the flow until you see the success screen, and tap Complete. You can learn more about the device linking journey in our Link UI guide.

Tapping Complete on this screen redirects to your specified redirect URL (the redirectUri parameter in the Link call from the previous step). Refer to our API referenceAPI for more details.

Copy linkStep 4: Fetch the user

After linking vehicles to your user, fetch the user using the /users/{userId} endpoint.

Sample

curl https://enode-api.sandbox.enode.io/users/1ab23cd4 \
-X GET \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}"

With correct values, you'll receive a response containing the user object. The linkedVendors array should include the vendor linked in step 3.

Sample

{
  "id": "1ab23cd4",
  "linkedVendors": [
    {
      "vendor": "{YOUR_LINKED_VENDOR}", // For example: "TESLA", "VOLKSWAGEN"
      "isValid": true
    },
    // If you linked additional vendors, they will show up here
  ]
}

Copy linkAll done!

Congratulations on making your first call to the Enode API! To learn more about using our API, you have a couple of options:

Read our integration guide

The integration journey with Enode

Browse our API reference

The ins and outs of our endpoints

Was this article helpful?