> ## Documentation Index
> Fetch the complete documentation index at: https://cpgrams.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Categorize Grievance

> Categorize a grievance text

Analyzes and categorizes grievance text to determine the appropriate category. This endpoint uses natural language processing to classify the grievance text and extract structured information.

## Request

The request requires a text field containing the grievance content to be categorized.

## Response

The response includes:

* `status`: Operation status
* `category`: The classified category of the grievance
* `confidence`: A confidence score (0-1) indicating the reliability of the classification
* `formatted_fields`: Structured information extracted from the grievance text, which may include entities, key phrases, and other relevant data points

This endpoint is useful for automatically categorizing new grievances or re-categorizing existing ones to ensure proper routing and handling.


## OpenAPI

````yaml POST /category
openapi: 3.1.0
info:
  title: CPGRAMS Simulation API
  description: >-
    An API that simulates the Centralized Public Grievance Redress and
    Monitoring System (CPGRAMS) in India
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://grm-api.vercel.app
security:
  - bearerAuth: []
externalDocs:
  description: API Documentation
  url: https://grm-api.vercel.app/docs
paths:
  /category:
    post:
      tags:
        - category
      description: Categorize a grievance text
      requestBody:
        description: Grievance text to categorize
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GrievanceCategoryRequest'
        required: true
      responses:
        '200':
          description: Categorization result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GrievanceCategoryResponse'
        '400':
          description: Bad request - Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    GrievanceCategoryRequest:
      required:
        - text
      type: object
      properties:
        text:
          type: string
          description: The grievance text to be categorized
    GrievanceCategoryResponse:
      type: object
      properties:
        status:
          type: string
          description: Status of the operation
        category:
          type: string
          description: The classified category of the grievance
        confidence:
          type: number
          format: float
          description: Confidence score of the classification
        formatted_fields:
          type: object
          description: Structured information extracted from the grievance text
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````