Overview
This guide walks through transitioning your existing integration from per-vehicle user tokens to application-level access tokens using API Authentication. Important: This migration is optional. Your existing per-vehicle user tokens continue to work indefinitely. Migrate at your own pace.Before You Begin
Ensure you have the following:- Active Smartcar developer account with dashboard access
- Existing integration using per-vehicle user tokens and Smartcar Connect
- Ability to update your backend database schema
- Development and staging environments ready for testing
- Team familiarity with your current token storage approach
Migration Overview
The transition follows four steps. You control the pace.- Create API credentials — Generate your Client ID and Secret in the Dashboard
- Capture
user_idfrom Connect — Store theuser_idreturned in the Connect redirect URL - Backfill existing connections — Use the Connections endpoint to retrieve user IDs for existing connections
- Switch to application tokens — Replace per-vehicle user tokens with your application access token +
sc-user-idheader
Phase 1: Enable API Authentication (Parallel Operation)
Create API credentials in Dashboard
- Log in to your Smartcar Dashboard
- Navigate to API Credentials in your application settings
- Click Create Secret
- Copy the
client_idandclient_secretand store them securely
Continue using per-vehicle user tokens
Keep your existing token refresh and storage logic unchanged. You’ll phase this out in Phase 3.
Test API Authentication
Exchange your credentials for an access token:
Access tokens are valid for 1 hour. Cache them and refresh when expired. Build a token refresh loop in Phase 2.
Phase 2: Update Integration
Capture userId from Connect redirect
When users complete Smartcar Connect, the redirect now includes a Update your callback handler to extract and store this userId:
userId parameter:Store userId ↔ user ID mappings
Create a new database column to store the Smartcar userId alongside your internal user ID. See the schema changes section below.
Phase 3: Full Migration
Remove per-vehicle user token refresh logic
Delete the code that refreshes per-vehicle user tokens. Application access tokens are re-requested from the token endpoint when expired.
Database Schema Changes
Before (Per-Vehicle User Tokens)
After (API Authentication with userId Mapping)
You can keep the
smartcar_vehicle_id for reference, but you no longer need token storage.Code Changes: Before & After
Testing Your Migration
Use this checklist to validate each phase: Phase 1 Validation:- API credentials created and stored securely
- Access token obtained successfully
- Staging environment receives access token
- Test API call with access token returns same data as per-vehicle user token call
- Both opaque and access token calls work in parallel without conflicts
-
userIdcaptured from Connect redirect -
smartcar_user_idstored in user database - Connections query with
userIdfilter returns results - Webhook handler routes events correctly using
user.id - Old per-vehicle user token calls still work for existing connections
- All API calls updated to use access token +
sc-user-idheader - Token refresh loop running and caching access tokens
- Opaque token refresh code removed from codebase
- Database migration completed (
vehicle_access_tokenremoved) - Production traffic flows through API Authentication
- No errors in error logs for authentication failures
Rollback Plan
If you encounter issues, rolling back is simple:- Phase 1 Rollback: Delete API credentials from the Dashboard. No code changes needed.
-
Phase 2 Rollback: Stop consuming
userIdfrom Connect redirect. Revert webhook handler to previous version. Per-vehicle user tokens still work. - Phase 3 Rollback: Restore per-vehicle user token refresh logic from version control. Redeploy previous code. Vehicles remain connected.
Because per-vehicle user tokens continue to work indefinitely, you can roll back at any phase without losing access to vehicles.
What’s Next
- Setup Guide — Complete implementation steps
- FAQ — Common questions and answers
- Webhooks Overview — Set up event-driven updates
- Connections API — Manage vehicle connections

