curl --request POST \
--url https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'sc-user-id: <sc-user-id>' \
--data '
{
"data": {
"attributes": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
}
}
}
'import requests
url = "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek"
payload = { "data": { "attributes": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
} } }
headers = {
"sc-user-id": "<sc-user-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'sc-user-id': '<sc-user-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {
attributes: {
location: {latitude: 37.7749, longitude: -122.4194},
weekdays: {startTime: '08:00', stopTime: '10:00'},
weekends: {startTime: '10:00', stopTime: '12:00'}
}
}
})
};
fetch('https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'attributes' => [
'location' => [
'latitude' => 37.7749,
'longitude' => -122.4194
],
'weekdays' => [
'startTime' => '08:00',
'stopTime' => '10:00'
],
'weekends' => [
'startTime' => '10:00',
'stopTime' => '12:00'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"sc-user-id: <sc-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("sc-user-id", "<sc-user-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek")
.header("sc-user-id", "<sc-user-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["sc-user-id"] = '<sc-user-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "exec_u30M8e5ErKC8wPc5t3uTXw",
"type": "charge-schedule-execution",
"attributes": {
"action": "create",
"scheduleType": "workweek",
"status": {
"value": "SUCCESS"
},
"executionMode": "sync",
"userId": "user_789xyz",
"vehicleId": "36ab27d0-fd9d-4455-823a-ce30af709ffc",
"scheduleId": "5e7a2b9c-8d1f-4e3a-a6c4-2b9f0d7e1c85",
"parameters": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
}
},
"links": {
"self": "https://vehicle.api.smartcar.com/v3/charge-schedule-executions/exec_u30M8e5ErKC8wPc5t3uTXw"
},
"meta": {
"executedAt": "2024-01-01T12:00:00Z",
"requestId": "3f9a2c1b-7d4e-4b8a-9c6f-1e2d3a4b5c6d",
"completedAt": "2024-01-01T12:00:02Z",
"durationInSeconds": 2
}
}
}Set workweek charge schedule
Set workweek charge schedule with separate time windows for weekdays and weekends.
Waits up to the request’s wait time (see Prefer). Finished in time:
200 with the execution, or the error status with an ErrorResponse.
Still running: 202 with the execution PENDING; poll Location every
Retry-After seconds until status.value is not PENDING.
Conflicts with another create of the same schedule type for the same location in progress on this vehicle.
curl --request POST \
--url https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'sc-user-id: <sc-user-id>' \
--data '
{
"data": {
"attributes": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
}
}
}
'import requests
url = "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek"
payload = { "data": { "attributes": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
} } }
headers = {
"sc-user-id": "<sc-user-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'sc-user-id': '<sc-user-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {
attributes: {
location: {latitude: 37.7749, longitude: -122.4194},
weekdays: {startTime: '08:00', stopTime: '10:00'},
weekends: {startTime: '10:00', stopTime: '12:00'}
}
}
})
};
fetch('https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'attributes' => [
'location' => [
'latitude' => 37.7749,
'longitude' => -122.4194
],
'weekdays' => [
'startTime' => '08:00',
'stopTime' => '10:00'
],
'weekends' => [
'startTime' => '10:00',
'stopTime' => '12:00'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"sc-user-id: <sc-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("sc-user-id", "<sc-user-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek")
.header("sc-user-id", "<sc-user-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vehicle.api.smartcar.com/v3/vehicles/{vehicleId}/charge-schedules/workweek")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["sc-user-id"] = '<sc-user-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"location\": {\n \"latitude\": 37.7749,\n \"longitude\": -122.4194\n },\n \"weekdays\": {\n \"startTime\": \"08:00\",\n \"stopTime\": \"10:00\"\n },\n \"weekends\": {\n \"startTime\": \"10:00\",\n \"stopTime\": \"12:00\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "exec_u30M8e5ErKC8wPc5t3uTXw",
"type": "charge-schedule-execution",
"attributes": {
"action": "create",
"scheduleType": "workweek",
"status": {
"value": "SUCCESS"
},
"executionMode": "sync",
"userId": "user_789xyz",
"vehicleId": "36ab27d0-fd9d-4455-823a-ce30af709ffc",
"scheduleId": "5e7a2b9c-8d1f-4e3a-a6c4-2b9f0d7e1c85",
"parameters": {
"location": {
"latitude": 37.7749,
"longitude": -122.4194
},
"weekdays": {
"startTime": "08:00",
"stopTime": "10:00"
},
"weekends": {
"startTime": "10:00",
"stopTime": "12:00"
}
}
},
"links": {
"self": "https://vehicle.api.smartcar.com/v3/charge-schedule-executions/exec_u30M8e5ErKC8wPc5t3uTXw"
},
"meta": {
"executedAt": "2024-01-01T12:00:00Z",
"requestId": "3f9a2c1b-7d4e-4b8a-9c6f-1e2d3a4b5c6d",
"completedAt": "2024-01-01T12:00:02Z",
"durationInSeconds": 2
}
}
}Authorizations
Headers
The identifier of the vehicle user on whose behalf the command is being executed.
Vehicle commands require both the vehicleId (path) and sc-user-id (header) to
identify the specific vehicle and the user who has granted permission to act on it.
The bearer token is a machine-to-machine token and does not carry per-user context,
so this header must be provided explicitly for every command request.
Use wait=<seconds> to set how long the server waits for the request to
finish. If it is still running when the wait ends, the response is 202
with the execution in PENDING status.
- Minimum
0: always returns202immediately. - Maximum
150: a longer wait is reduced to 150. - Default
60: used whenwaitis missing or is not a whole number.
Response
200 OK - The schedule was created within the wait time. The body holds the result.
Response to a charge schedule create or delete request. data.attributes.action identifies the operation ("create" or "delete"). data.attributes.scheduleId is the id of the schedule: for a create, it appears once the schedule has been created successfully; for a delete, it is the id from the request path. data.links.self contains the URL of this execution resource.
Was this page helpful?

