> ## 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.

# Create Grievance

> Creates a new grievance in the Xata database

Creates a new grievance in the Xata database. This endpoint requires authentication via a bearer token. Required fields include `title`, `description`, `category`, and `user_id`. The user must exist in the system, otherwise a 404 error is returned.

The grievance is created with a default status of "pending" and timestamps are automatically generated. Additional fields like `priority`, `cpgrams_category`, `reformed_top_level_category`, `reformed_last_level_category`, and `reformed_flag` can be provided as needed.

The response includes the ID of the created grievance and a status message indicating successful creation.


## OpenAPI

````yaml POST /grievances
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:
  /grievances:
    post:
      description: Creates a new grievance in the Xata database
      requestBody:
        description: Grievance to add to the system
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GrievanceCreate'
        required: true
      responses:
        '201':
          description: Grievance created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GrievanceCreateResponse'
        '404':
          description: User not found
          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:
    GrievanceCreate:
      required:
        - title
        - description
        - category
        - user_id
      type: object
      properties:
        title:
          description: Title of the grievance
          type: string
        description:
          description: Detailed description of the grievance
          type: string
        category:
          description: Category of the grievance
          type: string
        user_id:
          description: ID of the user submitting the grievance
          type: string
        priority:
          description: 'Priority level: low, medium, high, critical'
          type: string
          default: medium
        cpgrams_category:
          description: CPGRAMS category of the grievance
          type: string
        reformed_top_level_category:
          description: Top level category in the reformed classification
          type: string
        reformed_last_level_category:
          description: Last level category in the reformed classification
          type: string
        reformed_flag:
          description: Flag indicating if the grievance is part of reformed process
          type: boolean
          default: false
    GrievanceCreateResponse:
      type: object
      properties:
        id:
          type: string
          description: ID of the created grievance
        status:
          type: string
          description: Status message
        title:
          description: Title of the grievance
          type: string
        description:
          type: string
          description: Description of the grievance
        priority:
          type: string
          description: Priority level of the grievance
        user_id:
          description: ID of the user who submitted the grievance
          type: string
        cpgrams_category:
          description: CPGRAMS category of the grievance
          type: string
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````