create_document_type
Define custom document types in Paperless-NGX by specifying a name, matching criteria, and algorithm for document classification. Streamline organization and retrieval.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| match | No | ||
| matching_algorithm | No | ||
| name | Yes |
Implementation Reference
- src/tools/documentTypes.ts:77-84 (handler)Executes the tool logic: checks API, calls createDocumentType on API, enhances response, returns as text content.withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const response = await api.createDocumentType(args); const enhancedDocumentType = enhanceMatchingAlgorithm(response); return { content: [{ type: "text", text: JSON.stringify(enhancedDocumentType) }], }; })
- src/tools/documentTypes.ts:66-76 (schema)Zod input schema: name (required string), match (optional string), matching_algorithm (optional int 0-6 with desc).{ name: z.string(), match: z.string().optional(), matching_algorithm: z .number() .int() .min(0) .max(6) .optional() .describe(MATCHING_ALGORITHM_DESCRIPTION), },
- src/tools/documentTypes.ts:64-85 (registration)Full server.tool registration of the create_document_type tool, including name, schema, and handler.server.tool( "create_document_type", { name: z.string(), match: z.string().optional(), matching_algorithm: z .number() .int() .min(0) .max(6) .optional() .describe(MATCHING_ALGORITHM_DESCRIPTION), }, withErrorHandling(async (args, extra) => { if (!api) throw new Error("Please configure API connection first"); const response = await api.createDocumentType(args); const enhancedDocumentType = enhanceMatchingAlgorithm(response); return { content: [{ type: "text", text: JSON.stringify(enhancedDocumentType) }], }; }) );
- src/api/PaperlessAPI.ts:248-253 (helper)API client method that POSTs to /document_types/ endpoint to create the document type.async createDocumentType(data: Partial<DocumentType>): Promise<DocumentType> { return this.request<DocumentType>("/document_types/", { method: "POST", body: JSON.stringify(data), }); }
- src/index.ts:72-72 (registration)Top-level call to register all document type tools, including create_document_type.registerDocumentTypeTools(server, api);