create_identity_custom_field
Creates a new custom field for identities, defining a text, number, date, dropdown, or email field to standardize identity data across the organization.
Instructions
Create a new identity custom field for an organization. Defines a new field that can be used across all identities in the organization.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | Yes | The type of the custom field (REQUIRED) | |
| configuration | No | Dropdown configuration (values can be added, removed, reordered, or modified). Only required for dropdown type fields. | |
| attributeName | Yes | Display label for the custom field (REQUIRED) | |
| attributeCode | Yes | Unique identifier for the custom field. Must contain only lowercase letters, numbers, and underscores. If not provided, will be auto-generated. | |
| serviceSource | No | Optional service source to link this custom field to a specific service workspace. |
Implementation Reference
- The main handler function that creates an identity custom field by making a POST API call to /identity/fields/custom. It constructs a body with kind, attributeName, attributeCode, optional dropdown configuration, and optional serviceSource.
export async function createIdentityCustomField(params: CreateIdentityCustomFieldParams) { const client = getClient(); const body: Record<string, unknown> = { kind: params.kind, attributeName: params.attributeName, attributeCode: params.attributeCode, configuration: params.kind === "dropdown" ? params.configuration : null, }; if (params.serviceSource) { body.serviceSource = { serviceFieldId: params.serviceSource.serviceFieldId, workspaceId: params.serviceSource.workspaceId, }; } return client.makePostApiCall("/identity/fields/custom", new URLSearchParams(), body); } - Zod schema defining the input parameters for create_identity_custom_field: kind (enum), configuration (dropdown schema), attributeName, attributeCode, and optional serviceSource.
export const CreateIdentityCustomFieldSchema = z.object({ kind: z .enum(["text", "textarea", "number", "date", "dropdown", "email"]) .describe("The type of the custom field (REQUIRED)"), configuration: DropdownConfigurationSchema.describe( "Dropdown items with id (stable identifier) and value (display name) (REQUIRED)", ) .optional() .describe( "Dropdown configuration (values can be added, removed, reordered, or modified). Only required for dropdown type fields.", ), attributeName: z.string().describe("Display label for the custom field (REQUIRED)"), attributeCode: z .string() .describe( "Unique identifier for the custom field. Must contain only lowercase letters, numbers, and underscores. If not provided, will be auto-generated.", ), serviceSource: z .object({ serviceFieldId: z .string() .describe( "Display label for the custom field (REQUIRED). This can be obtained as workspaceId of workspace of service field from get_services tool and user should pick a service then pick a workspace from the list of workspaces for that service and use that workspaceId for this field", ), workspaceId: z .number() .describe("Workspace ID number for the service source. This can be obtained from the get_services tool."), }) .optional() .describe("Optional service source to link this custom field to a specific service workspace."), }); - src/index.ts:272-277 (registration)Registration of the tool in the ListToolsRequestSchema handler with name 'create_identity_custom_field' and description.
{ name: "create_identity_custom_field", description: "Create a new identity custom field for an organization. Defines a new field that can be used across all identities in the organization.", inputSchema: zodToJsonSchema(CreateIdentityCustomFieldSchema), }, - src/index.ts:328-329 (registration)Handler mapping in the toolHandlers object that routes 'create_identity_custom_field' to the createIdentityCustomField function.
create_identity_custom_field: async (input) => createIdentityCustomField(CreateIdentityCustomFieldSchema.parse(input)), - src/common/dropdown-schema.ts:1-13 (helper)DropdownConfigurationSchema helper used by CreateIdentityCustomFieldSchema to validate dropdown configuration values.
import z from "zod"; // Dropdown value schema export const DropdownValueSchema = z.object({ id: z.string().describe("Stable identifier for the option"), value: z.string().describe("Display name for the option"), group: z.string().optional().describe("Optional group for the option"), }); // Dropdown configuration schema export const DropdownConfigurationSchema = z.object({ values: z.array(DropdownValueSchema).describe("Dropdown items with id (stable identifier) and value (display name)"), });