ninja_update_device_custom_fields
Update custom field values for a device by specifying the device ID and custom field key-value pairs.
Instructions
Update custom field values for a device.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Device ID | |
| fields | Yes | Key-value pairs of custom field names to their new values |
Implementation Reference
- src/tools/devices.ts:374-376 (handler)The handler function that executes the tool logic — calls PATCH /device/{id}/custom-fields with the provided fields object to update custom field values for a device.
handler: async ({ id, fields }, client: NinjaOneClient) => client.patch(`/device/${id}/custom-fields`, fields), }, - src/tools/devices.ts:357-372 (schema)The tool definition including name, description, and inputSchema — requires 'id' (number) and 'fields' (object with key-value pairs of custom field names to values).
{ tool: { name: 'ninja_update_device_custom_fields', description: 'Update custom field values for a device.', inputSchema: { type: 'object', required: ['id', 'fields'], properties: { id: { type: 'number', description: 'Device ID' }, fields: { type: 'object', description: 'Key-value pairs of custom field names to their new values', additionalProperties: true, }, }, }, - src/tools/index.ts:13-24 (registration)The tool is registered as part of deviceTools which is spread into ALL_TOOLS, then indexed by name into toolMap in src/index.ts via the ListToolsRequestSchema and CallToolRequestSchema handlers.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/client.ts:70-79 (helper)The NinjaOneClient.patch method used by the handler to send the HTTP PATCH request to the NinjaOne API.
async patch<T = unknown>(path: string, body?: unknown): Promise<T> { try { const res = await this.http.patch<T>(path, body, { headers: await this.authHeader(), }); return res.data; } catch (err) { throw new Error(`PATCH ${path} failed: ${apiError(err)}`); } }