Skip to content

Updating Data Types

Modify existing custom data types using PUT (full replacement) or PATCH (partial update) operations.

Note: Built-in data types cannot be modified.


PUT /api/datatypes/:type

Replace the entire data type with new configuration. All fields must be provided.

Endpoint

PUT /api/datatypes/:type

Authentication

Requires API Key with Admin permission.

Request Body

Same as creating a data type - all fields required.

Response

Returns the updated data type object with the new configuration.


PATCH /api/datatypes/:type

Partially update a data type. Only specified fields are modified.

Endpoint

PATCH /api/datatypes/:type

Authentication

Requires API Key with Admin permission.

Request Body

Provide only the fields you want to update:

{
  "description": "Updated description"
}

Response

Returns the updated data type object:

{
  "id": "employee_id",
  "type": "EMPLOYEE_ID",
  "name": "Employee ID",
  "description": "Updated description",
  "disabled": false,
  "isGroupDataType": false,
  "regexes": [...],
  "updatedAt": 1704240000
}

Examples

Update Data Type Description

Change only the description field using PATCH.

DATATYPE_TYPE="EMPLOYEE_ID"

curl -X PATCH "https://your-shield-host:8080/api/datatypes/$DATATYPE_TYPE" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description": "Updated employee identifier format"}'
import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

datatype_type = "EMPLOYEE_ID"

response = requests.patch(
    f"{BASE_URL}/api/datatypes/{datatype_type}",
    headers=HEADERS,
    json={"description": "Updated employee identifier format"}
)

print(f"Updated: {response.json()['description']}")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

const datatypeType = 'EMPLOYEE_ID';

const response = await axios.patch(
  `${BASE_URL}/api/datatypes/${datatypeType}`,
  { description: 'Updated employee identifier format' },
  { headers: HEADERS }
);

console.log(`Updated: ${response.data.description}`);
Update Regex Pattern

Replace the regex patterns for an existing data type.

import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

datatype_type = "EMPLOYEE_ID"

# Update with new regex pattern
update = {
    "regexes": [
        {
            "regex": "EMP-[0-9]{8}",  # Changed from 6 to 8 digits
            "json": "",
            "html": "",
            "valueGroupIndex": 0
        }
    ]
}

response = requests.patch(
    f"{BASE_URL}/api/datatypes/{datatype_type}",
    headers=HEADERS,
    json=update
)

print(f"Updated regex: {response.json()['regexes'][0]['regex']}")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

const datatypeType = 'EMPLOYEE_ID';

// Update with new regex pattern
const update = {
  regexes: [
    {
      regex: 'EMP-[0-9]{8}',  // Changed from 6 to 8 digits
      json: '',
      html: '',
      valueGroupIndex: 0
    }
  ]
};

const response = await axios.patch(
  `${BASE_URL}/api/datatypes/${datatypeType}`,
  update,
  { headers: HEADERS }
);

console.log(`Updated regex: ${response.data.regexes[0].regex}`);
Update Group Members

Modify the member types in a group data type.

import requests

BASE_URL = "https://your-shield-host:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

# Get current data types
response = requests.get(f"{BASE_URL}/api/datatypes", headers=HEADERS)
types = {t["type"]: t["id"] for t in response.json()["items"]}

# Update group to include additional types
group_id = "group-uuid-here"
update = {
    "dataTypes": [
        types["credit_card"],
        types["bank_account"],
        types["routing_number"]  # Added new member
    ]
}

response = requests.patch(
    f"{BASE_URL}/api/datatypes/{group_id}",
    headers=HEADERS,
    json=update
)

print(f"Group now has {len(response.json()['dataTypes'])} members")
const axios = require('axios');

const BASE_URL = 'https://your-shield-host:8080';
const HEADERS = { 'Authorization': 'Bearer YOUR_API_KEY' };

// Get current data types
const response = await axios.get(`${BASE_URL}/api/datatypes`, { headers: HEADERS });
const types = response.data.items.reduce((acc, t) => {
  acc[t.type] = t.id;
  return acc;
}, {});

// Update group to include additional types
const groupId = 'group-uuid-here';
const update = {
  dataTypes: [
    types['credit_card'],
    types['bank_account'],
    types['routing_number']  // Added new member
  ]
};

const updateResponse = await axios.patch(
  `${BASE_URL}/api/datatypes/${groupId}`,
  update,
  { headers: HEADERS }
);

console.log(`Group now has ${updateResponse.data.dataTypes.length} members`);

Error Responses

Status Code Description
400 Invalid request body or validation error
401 Invalid or expired API key
403 Insufficient permissions or attempting to modify built-in type
404 Data type not found
409 Data type identifier already exists (when changing type field)