Create Entity Type
Create a new entity type with optional fields for a team.
curl --request POST \
--url https://public.api.serval.com/v2/entity-types \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"fields": [
{
"key": "<string>",
"name": "<string>",
"enumOptions": [
{
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": true,
"isNameField": true,
"refEntityTypeId": "<string>"
}
],
"parentEntityTypeId": "<string>",
"schemaKey": "<string>",
"isEdgeType": true
}
'import requests
url = "https://public.api.serval.com/v2/entity-types"
payload = {
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"fields": [
{
"key": "<string>",
"name": "<string>",
"enumOptions": [
{
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": True,
"isNameField": True,
"refEntityTypeId": "<string>"
}
],
"parentEntityTypeId": "<string>",
"schemaKey": "<string>",
"isEdgeType": True
}
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({
teamId: '<string>',
key: '<string>',
name: '<string>',
fields: [
{
key: '<string>',
name: '<string>',
enumOptions: [{value: '<string>', displayName: '<string>', displayOrder: 123}],
isKeyField: true,
isNameField: true,
refEntityTypeId: '<string>'
}
],
parentEntityTypeId: '<string>',
schemaKey: '<string>',
isEdgeType: true
})
};
fetch('https://public.api.serval.com/v2/entity-types', 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://public.api.serval.com/v2/entity-types",
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([
'teamId' => '<string>',
'key' => '<string>',
'name' => '<string>',
'fields' => [
[
'key' => '<string>',
'name' => '<string>',
'enumOptions' => [
[
'value' => '<string>',
'displayName' => '<string>',
'displayOrder' => 123
]
],
'isKeyField' => true,
'isNameField' => true,
'refEntityTypeId' => '<string>'
]
],
'parentEntityTypeId' => '<string>',
'schemaKey' => '<string>',
'isEdgeType' => true
]),
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://public.api.serval.com/v2/entity-types"
payload := strings.NewReader("{\n \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\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://public.api.serval.com/v2/entity-types")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.api.serval.com/v2/entity-types")
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 \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"parentEntityTypeId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>",
"fields": [
{
"id": "<string>",
"entityTypeId": "<string>",
"key": "<string>",
"name": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>",
"enumOptions": [
{
"id": "<string>",
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": true,
"isNameField": true,
"refEntityTypeId": "<string>",
"description": "<string>",
"sourceEntityTypeId": "<string>",
"sectionId": "<string>"
}
],
"color": "<string>",
"iconSlug": "<string>",
"entitySchemaId": "<string>",
"sections": [
{
"id": "<string>",
"entityTypeId": "<string>",
"name": "<string>",
"sourceEntityTypeId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>"
}
],
"isEdgeType": true,
"description": "<string>"
}
}{
"message": "<string>",
"detail": {
"type": "<string>",
"value": "<string>",
"debug": {}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The ID of the team.
The unique key for the entity type. If not provided, will be auto-generated from the name.
The display name of the entity type (required).
The fields to create on the entity type.
Show child attributes
Show child attributes
Optional parent entity type ID for nesting under a parent type.
Optional schema key for placing the entity type in a non-default schema. When omitted, the entity type is created in the team's default schema. Use "reference-data" for entity types that represent external reference tables (e.g., ServiceNow reference tables) rather than user-facing assets.
Controls whether the help agent can see entities of this type. Defaults to REQUESTER_ASSOCIATED if not specified.
HELP_AGENT_ENTITY_VISIBILITY_UNSPECIFIED, HELP_AGENT_ENTITY_VISIBILITY_NONE, HELP_AGENT_ENTITY_VISIBILITY_REQUESTER_ASSOCIATED, HELP_AGENT_ENTITY_VISIBILITY_ALWAYS When true, marks the type as an edge/relationship type whose instances
connect two other entities. The type must have exactly two single-valued
ENTITY_REF fields in fields (the endpoints); direction labels are
derived from those field names, so no extra edge config is needed.
Response
Success
The created entity type.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://public.api.serval.com/v2/entity-types \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"fields": [
{
"key": "<string>",
"name": "<string>",
"enumOptions": [
{
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": true,
"isNameField": true,
"refEntityTypeId": "<string>"
}
],
"parentEntityTypeId": "<string>",
"schemaKey": "<string>",
"isEdgeType": true
}
'import requests
url = "https://public.api.serval.com/v2/entity-types"
payload = {
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"fields": [
{
"key": "<string>",
"name": "<string>",
"enumOptions": [
{
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": True,
"isNameField": True,
"refEntityTypeId": "<string>"
}
],
"parentEntityTypeId": "<string>",
"schemaKey": "<string>",
"isEdgeType": True
}
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({
teamId: '<string>',
key: '<string>',
name: '<string>',
fields: [
{
key: '<string>',
name: '<string>',
enumOptions: [{value: '<string>', displayName: '<string>', displayOrder: 123}],
isKeyField: true,
isNameField: true,
refEntityTypeId: '<string>'
}
],
parentEntityTypeId: '<string>',
schemaKey: '<string>',
isEdgeType: true
})
};
fetch('https://public.api.serval.com/v2/entity-types', 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://public.api.serval.com/v2/entity-types",
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([
'teamId' => '<string>',
'key' => '<string>',
'name' => '<string>',
'fields' => [
[
'key' => '<string>',
'name' => '<string>',
'enumOptions' => [
[
'value' => '<string>',
'displayName' => '<string>',
'displayOrder' => 123
]
],
'isKeyField' => true,
'isNameField' => true,
'refEntityTypeId' => '<string>'
]
],
'parentEntityTypeId' => '<string>',
'schemaKey' => '<string>',
'isEdgeType' => true
]),
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://public.api.serval.com/v2/entity-types"
payload := strings.NewReader("{\n \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\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://public.api.serval.com/v2/entity-types")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.api.serval.com/v2/entity-types")
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 \"teamId\": \"<string>\",\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"fields\": [\n {\n \"key\": \"<string>\",\n \"name\": \"<string>\",\n \"enumOptions\": [\n {\n \"value\": \"<string>\",\n \"displayName\": \"<string>\",\n \"displayOrder\": 123\n }\n ],\n \"isKeyField\": true,\n \"isNameField\": true,\n \"refEntityTypeId\": \"<string>\"\n }\n ],\n \"parentEntityTypeId\": \"<string>\",\n \"schemaKey\": \"<string>\",\n \"isEdgeType\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"teamId": "<string>",
"key": "<string>",
"name": "<string>",
"parentEntityTypeId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>",
"fields": [
{
"id": "<string>",
"entityTypeId": "<string>",
"key": "<string>",
"name": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>",
"enumOptions": [
{
"id": "<string>",
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": true,
"isNameField": true,
"refEntityTypeId": "<string>",
"description": "<string>",
"sourceEntityTypeId": "<string>",
"sectionId": "<string>"
}
],
"color": "<string>",
"iconSlug": "<string>",
"entitySchemaId": "<string>",
"sections": [
{
"id": "<string>",
"entityTypeId": "<string>",
"name": "<string>",
"sourceEntityTypeId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"createdByUserId": "<string>",
"updatedByUserId": "<string>"
}
],
"isEdgeType": true,
"description": "<string>"
}
}{
"message": "<string>",
"detail": {
"type": "<string>",
"value": "<string>",
"debug": {}
}
}
