Create subscription
curl --request POST \
--url https://management.api.smartcar.com/v3/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"attributes": {
"webhookId": "webhook_12345",
"userId": "user_12345",
"vehicleId": "vehicle_67890"
}
}
}
'import requests
url = "https://management.api.smartcar.com/v3/subscriptions"
payload = { "data": { "attributes": {
"webhookId": "webhook_12345",
"userId": "user_12345",
"vehicleId": "vehicle_67890"
} } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
attributes: {webhookId: 'webhook_12345', userId: 'user_12345', vehicleId: 'vehicle_67890'}
}
})
};
fetch('https://management.api.smartcar.com/v3/subscriptions', 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://management.api.smartcar.com/v3/subscriptions",
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' => [
'webhookId' => 'webhook_12345',
'userId' => 'user_12345',
'vehicleId' => 'vehicle_67890'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://management.api.smartcar.com/v3/subscriptions"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://management.api.smartcar.com/v3/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://management.api.smartcar.com/v3/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"message": "subscription creation in progress"
}
}{
"errors": [
{
"status": "400",
"type": "VALIDATION",
"code": "BAD_REQUEST",
"title": "Bad Request",
"detail": "The request could not be understood by the server due to malformed syntax.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/validation-errors"
}
}
]
}{
"errors": [
{
"status": "401",
"type": "AUTHENTICATION",
"code": "UNAUTHORIZED",
"title": "Unauthorized",
"detail": "The Authorization token is missing or invalid.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/authentication-errors#authentication"
}
}
]
}{
"errors": [
{
"status": "403",
"type": "AUTHENTICATION",
"code": "FORBIDDEN",
"title": "Forbidden",
"detail": "You do not have permission to access this resource.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/authentication-errors"
}
}
]
}{
"errors": [
{
"status": "404",
"type": "RESOURCE_NOT_FOUND",
"code": "NOT_FOUND",
"title": "Not Found",
"detail": "The requested resource could not be found.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/resource-not-found-errors"
}
}
]
}{
"errors": [
{
"status": "409",
"type": "VEHICLE_STATE",
"code": "ASLEEP",
"title": "Vehicle Asleep",
"detail": "The vehicle is in a sleep state and temporarily unable to perform your request.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/vehicle-state-errors#asleep"
}
}
]
}{
"errors": [
{
"status": "500",
"type": "SERVER",
"code": "INTERNAL",
"title": "Internal Server Error",
"detail": "An unexpected error occurred on the server.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/server-errors"
}
}
]
}Webhooks
Create subscription
Create a new webhook subscription.
POST
/
subscriptions
Create subscription
curl --request POST \
--url https://management.api.smartcar.com/v3/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"attributes": {
"webhookId": "webhook_12345",
"userId": "user_12345",
"vehicleId": "vehicle_67890"
}
}
}
'import requests
url = "https://management.api.smartcar.com/v3/subscriptions"
payload = { "data": { "attributes": {
"webhookId": "webhook_12345",
"userId": "user_12345",
"vehicleId": "vehicle_67890"
} } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
attributes: {webhookId: 'webhook_12345', userId: 'user_12345', vehicleId: 'vehicle_67890'}
}
})
};
fetch('https://management.api.smartcar.com/v3/subscriptions', 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://management.api.smartcar.com/v3/subscriptions",
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' => [
'webhookId' => 'webhook_12345',
'userId' => 'user_12345',
'vehicleId' => 'vehicle_67890'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://management.api.smartcar.com/v3/subscriptions"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://management.api.smartcar.com/v3/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://management.api.smartcar.com/v3/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"webhookId\": \"webhook_12345\",\n \"userId\": \"user_12345\",\n \"vehicleId\": \"vehicle_67890\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"message": "subscription creation in progress"
}
}{
"errors": [
{
"status": "400",
"type": "VALIDATION",
"code": "BAD_REQUEST",
"title": "Bad Request",
"detail": "The request could not be understood by the server due to malformed syntax.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/validation-errors"
}
}
]
}{
"errors": [
{
"status": "401",
"type": "AUTHENTICATION",
"code": "UNAUTHORIZED",
"title": "Unauthorized",
"detail": "The Authorization token is missing or invalid.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/authentication-errors#authentication"
}
}
]
}{
"errors": [
{
"status": "403",
"type": "AUTHENTICATION",
"code": "FORBIDDEN",
"title": "Forbidden",
"detail": "You do not have permission to access this resource.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/authentication-errors"
}
}
]
}{
"errors": [
{
"status": "404",
"type": "RESOURCE_NOT_FOUND",
"code": "NOT_FOUND",
"title": "Not Found",
"detail": "The requested resource could not be found.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/resource-not-found-errors"
}
}
]
}{
"errors": [
{
"status": "409",
"type": "VEHICLE_STATE",
"code": "ASLEEP",
"title": "Vehicle Asleep",
"detail": "The vehicle is in a sleep state and temporarily unable to perform your request.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/vehicle-state-errors#asleep"
}
}
]
}{
"errors": [
{
"status": "500",
"type": "SERVER",
"code": "INTERNAL",
"title": "Internal Server Error",
"detail": "An unexpected error occurred on the server.",
"links": {
"about": "https://smartcar.com/docs/errors/api-errors/v3/server-errors"
}
}
]
}Authorizations
The Authorization header must be provided with a valid bearer token.
Example: Authorization: Bearer {token}
Body
application/json
Show child attributes
Show child attributes
Response
Subscription creation accepted and in progress
Show child attributes
Show child attributes
Was this page helpful?
⌘I

