Create Custom Field
create_custom_fieldCreate a new custom field for your contacts to store additional data. Specify a name and field type (Text, Number, or Date).
Instructions
Create a new custom field for contacts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the custom field | |
| field_type | Yes | Type of the field |
Implementation Reference
- src/tools/contacts.ts:197-208 (handler)Handler function that creates a custom field by POSTing to SendGrid's field_definitions API with name and field_type
handler: async ({ name, field_type }: { name: string; field_type: string }): Promise<ToolResult> => { const readOnlyCheck = checkReadOnlyMode(); if (readOnlyCheck.blocked) { return { content: [{ type: "text", text: readOnlyCheck.message! }] }; } const result = await makeRequest("https://api.sendgrid.com/v3/marketing/field_definitions", { method: "POST", body: JSON.stringify({ name, field_type }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, - src/tools/contacts.ts:189-196 (schema)Schema definition for create_custom_field tool with name (string) and field_type (enum: Text, Number, Date)
config: { title: "Create Custom Field", description: "Create a new custom field for contacts", inputSchema: { name: z.string().describe("Name of the custom field"), field_type: z.enum(["Text", "Number", "Date"]).describe("Type of the field"), }, }, - src/tools/contacts.ts:188-209 (registration)Registration of create_custom_field as a property of contactTools object in src/tools/contacts.ts
create_custom_field: { config: { title: "Create Custom Field", description: "Create a new custom field for contacts", inputSchema: { name: z.string().describe("Name of the custom field"), field_type: z.enum(["Text", "Number", "Date"]).describe("Type of the field"), }, }, handler: async ({ name, field_type }: { name: string; field_type: string }): Promise<ToolResult> => { const readOnlyCheck = checkReadOnlyMode(); if (readOnlyCheck.blocked) { return { content: [{ type: "text", text: readOnlyCheck.message! }] }; } const result = await makeRequest("https://api.sendgrid.com/v3/marketing/field_definitions", { method: "POST", body: JSON.stringify({ name, field_type }), }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }, }, - src/tools/index.ts:9-17 (registration)Re-export of contactTools (including create_custom_field) into the allTools aggregate
export const allTools = { ...automationTools, ...campaignTools, ...contactTools, ...mailTools, ...miscTools, ...statsTools, ...templateTools, }; - src/prompts/help.ts:117-123 (helper)Help prompt mentioning create_custom_field as part of custom fields management tools
Segments & Custom Fields: - list_segments: View segments with parent relationships - open_segment_creator: Open segment creator in browser - list_custom_fields: List custom field definitions - create_custom_field: Create new custom fields - update_custom_field: Update existing custom field definitions - delete_custom_field: Delete custom field definitions