Skip to main content
POST
/
v2
/
entity-type-fields
Create Entity Type Field
curl --request POST \
  --url https://public.api.serval.com/v2/entity-type-fields \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "entityTypeId": "<string>",
  "key": "<string>",
  "name": "<string>",
  "enumOptions": [
    {
      "value": "<string>",
      "displayName": "<string>",
      "displayOrder": 123
    }
  ],
  "isKeyField": true,
  "isNameField": true,
  "refEntityTypeId": "<string>"
}
'
import requests

url = "https://public.api.serval.com/v2/entity-type-fields"

payload = {
"entityTypeId": "<string>",
"key": "<string>",
"name": "<string>",
"enumOptions": [
{
"value": "<string>",
"displayName": "<string>",
"displayOrder": 123
}
],
"isKeyField": True,
"isNameField": True,
"refEntityTypeId": "<string>"
}
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({
entityTypeId: '<string>',
key: '<string>',
name: '<string>',
enumOptions: [{value: '<string>', displayName: '<string>', displayOrder: 123}],
isKeyField: true,
isNameField: true,
refEntityTypeId: '<string>'
})
};

fetch('https://public.api.serval.com/v2/entity-type-fields', 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-type-fields",
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([
'entityTypeId' => '<string>',
'key' => '<string>',
'name' => '<string>',
'enumOptions' => [
[
'value' => '<string>',
'displayName' => '<string>',
'displayOrder' => 123
]
],
'isKeyField' => true,
'isNameField' => true,
'refEntityTypeId' => '<string>'
]),
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-type-fields"

payload := strings.NewReader("{\n \"entityTypeId\": \"<string>\",\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}")

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-type-fields")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityTypeId\": \"<string>\",\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}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://public.api.serval.com/v2/entity-type-fields")

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 \"entityTypeId\": \"<string>\",\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}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "schemaMigrationId": "<string>"
  }
}
{
"message": "<string>",
"detail": {
"type": "<string>",
"value": "<string>",
"debug": {}
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
entityTypeId
string

The entity type to create the field on (required).

key
string | null

The unique key for the field. If omitted, derived from the name.

name
string

The display name of the field (required).

dataType
enum<string>

The data type of the field (required).

Available options:
DATA_TYPE_UNSPECIFIED,
TEXT,
NUMBER,
BOOL,
TIMESTAMP,
ENUM,
ENTITY_REF,
USER_REF,
UNIQUE,
MULTI_SELECT,
FILE
enumOptions
EnumOptionInput · object[]

Options for ENUM / MULTI_SELECT fields (required for those data types).

isKeyField
boolean

Whether this field is the entity type's key (dedup identity) field.

isNameField
boolean

Whether this field is the entity type's display-name field.

refEntityTypeId
string | null

For ENTITY_REF fields: the entity type this field references.

Response

Success

data
data · object

Reference to the (COMPLETED) create migration; its details.create_field.field_id is the new field id.