Learn how to design your backend to integrate your application with Smartcar.
Step 1: Plan Your Database Tables
Table | Purpose | Key Fields |
---|---|---|
users | You probably already have this table to store your app’s users. | id , email , name , etc. |
smartcar_tokens | Stores Smartcar access and refresh tokens pairs alongside your app’s user id and smartcar_user_id | id , your_app_user_id , smartcar_vehicle_id , smartcar_access_token , smartcar_refresh_token , expires_at , created_at , updated_at |
vehicles | Stores connected vehicle information | id , smartcar_user_id , your_app_user_id , make , model , year , created_at , updated_at |
vehicle_data | Stores data about your vehicles (i.e. odometer readings, location, etc.) | id , smartcar_vehicle_id , created_at , data_type , data_value |
webhook_logs | Log incoming webhook events (optional) | id , smartcar_vehicle_id , event_type , payload , received_at |
Step 2: Implement OAuth Code Exchange Endpoint
/api/smartcar/callback
code
and state
query parameters from Smartcar.tokens
table, linked to the user and vehicle.Step 3: Create a Webhook Receiver Endpoint
/api/webhooks/smartcar
webhook_logs
for auditing and debugging.Step 4: Secure Your Endpoints