Skip to main content
POST
/
v3
/
vehicles
Create a new vehicle
curl --request POST \
  --url https://api.ctrl-hub.com/v3/vehicles \
  --header 'Content-Type: application/vnd.api+json' \
  --header 'X-Session-Token: <api-key>' \
  --data '
{
  "data": {
    "type": "<string>",
    "attributes": {
      "registration": "<string>",
      "vin": "<string>",
      "description": "<string>",
      "colour": "<string>",
      "status": "<string>"
    },
    "relationships": {
      "organisation": {
        "data": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        }
      }
    }
  }
}
'
import requests

url = "https://api.ctrl-hub.com/v3/vehicles"

payload = { "data": {
"type": "<string>",
"attributes": {
"registration": "<string>",
"vin": "<string>",
"description": "<string>",
"colour": "<string>",
"status": "<string>"
},
"relationships": { "organisation": { "data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "<string>"
} } }
} }
headers = {
"X-Session-Token": "<api-key>",
"Content-Type": "application/vnd.api+json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-Session-Token': '<api-key>', 'Content-Type': 'application/vnd.api+json'},
body: JSON.stringify({
data: {
type: '<string>',
attributes: {
registration: '<string>',
vin: '<string>',
description: '<string>',
colour: '<string>',
status: '<string>'
},
relationships: {
organisation: {data: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', type: '<string>'}}
}
}
})
};

fetch('https://api.ctrl-hub.com/v3/vehicles', 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://api.ctrl-hub.com/v3/vehicles",
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' => [
'type' => '<string>',
'attributes' => [
'registration' => '<string>',
'vin' => '<string>',
'description' => '<string>',
'colour' => '<string>',
'status' => '<string>'
],
'relationships' => [
'organisation' => [
'data' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'type' => '<string>'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/vnd.api+json",
"X-Session-Token: <api-key>"
],
]);

$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://api.ctrl-hub.com/v3/vehicles"

payload := strings.NewReader("{\n \"data\": {\n \"type\": \"<string>\",\n \"attributes\": {\n \"registration\": \"<string>\",\n \"vin\": \"<string>\",\n \"description\": \"<string>\",\n \"colour\": \"<string>\",\n \"status\": \"<string>\"\n },\n \"relationships\": {\n \"organisation\": {\n \"data\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"<string>\"\n }\n }\n }\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Session-Token", "<api-key>")
req.Header.Add("Content-Type", "application/vnd.api+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://api.ctrl-hub.com/v3/vehicles")
.header("X-Session-Token", "<api-key>")
.header("Content-Type", "application/vnd.api+json")
.body("{\n \"data\": {\n \"type\": \"<string>\",\n \"attributes\": {\n \"registration\": \"<string>\",\n \"vin\": \"<string>\",\n \"description\": \"<string>\",\n \"colour\": \"<string>\",\n \"status\": \"<string>\"\n },\n \"relationships\": {\n \"organisation\": {\n \"data\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"<string>\"\n }\n }\n }\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.ctrl-hub.com/v3/vehicles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Session-Token"] = '<api-key>'
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n \"data\": {\n \"type\": \"<string>\",\n \"attributes\": {\n \"registration\": \"<string>\",\n \"vin\": \"<string>\",\n \"description\": \"<string>\",\n \"colour\": \"<string>\",\n \"status\": \"<string>\"\n },\n \"relationships\": {\n \"organisation\": {\n \"data\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"<string>\"\n }\n }\n }\n }\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "type": "<string>",
    "attributes": {
      "registration": "<string>",
      "vin": "<string>",
      "description": "<string>",
      "colour": "<string>",
      "status": "<string>"
    },
    "meta": {
      "created_at": "2023-11-07T05:31:56Z",
      "updated_at": "2023-11-07T05:31:56Z",
      "sorn": true,
      "has_recall": true,
      "last_odometer_reading": 123,
      "counts": {
        "equipment": 123
      },
      "mot": {
        "is_valid": true,
        "records": 123,
        "last": {
          "at": "2023-11-07T05:31:56Z",
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
        }
      },
      "tax": {
        "is_valid": true,
        "due": "<string>"
      },
      "checks": {
        "inventory": {
          "count": 123,
          "last": {
            "at": "2023-11-07T05:31:56Z",
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
          }
        },
        "inspection": {
          "count": 123,
          "last": {
            "at": "2023-11-07T05:31:56Z",
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
          }
        }
      },
      "dvla": {
        "mot": {
          "exists": true,
          "last_sync": "2023-11-07T05:31:56Z",
          "data": {}
        },
        "ves": {
          "exists": true,
          "last_sync": "2023-11-07T05:31:56Z",
          "data": {}
        }
      }
    },
    "relationships": {
      "organisation": {
        "data": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        }
      },
      "specification": {
        "data": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        }
      },
      "equipment": {
        "data": [
          {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "type": "<string>"
          }
        ]
      },
      "team": {
        "data": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        }
      },
      "assignee": {
        "data": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        }
      }
    }
  },
  "jsonapi": {
    "version": "<string>"
  },
  "included": [
    {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "type": "<string>",
      "attributes": {
        "serial": "<string>",
        "status": "<string>"
      },
      "meta": {
        "created_at": "2023-11-07T05:31:56Z",
        "updated_at": "2023-11-07T05:31:56Z"
      },
      "relationships": {
        "organisation": {
          "data": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "type": "<string>"
          }
        },
        "model": {
          "data": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "type": "<string>"
          }
        },
        "vehicle": {
          "data": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "type": "<string>"
          }
        }
      }
    }
  ]
}
{
"id": "98ca4a78-b66f-4234-9719-aaf832ee6669",
"status": "400",
"title": "A validation error was encountered",
"source": {
"parameter": "include"
},
"meta": {
"resource": "wrong_value"
}
}
{
"id": "05fc9c8d-73b9-4697-9337-57f7a567a48f",
"status": "401",
"title": "You are not authorised to access this resource",
"detail": "In order to access this resource, you need the 'admin' role.",
"code": "AUTH.001"
}
{
"id": "8e2f9a34-b5c6-4d7e-9f8a-2b3c4d5e6f7g",
"status": "409",
"title": "Conflict",
"detail": "The request conflicts with the current state of the resource.",
"code": "CONFLICT.001"
}
{
"id": "fe9d9a69-f0a7-4fdc-bb2c-176027f316c5",
"status": "500",
"title": "Internal Server Error",
"detail": "An unexpected error occurred on the server."
}

Authorizations

X-Session-Token
string
header
required

Session token for authentication.

Body

application/vnd.api+json

The vehicle to create.

data
object
required

Response

Get a vehicle.

JSON API response object

data
object
required

A vehicle

jsonapi
object
required
included
object[]

Related resources that can be included when a vehicle is returned.

An equipment item