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

# Cognify

> Transform datasets into structured knowledge graphs through cognitive processing.

This endpoint is the core of Cognee's intelligence layer, responsible for converting
raw text, documents, and data added through the add endpoint into semantic knowledge graphs.
It performs deep analysis to extract entities, relationships, and insights from ingested content.

## Processing Pipeline
1. Document classification and permission validation
2. Text chunking and semantic segmentation
3. Entity extraction using LLM-powered analysis
4. Relationship detection and graph construction
5. Vector embeddings generation for semantic search
6. Content summarization and indexing

## Request Parameters
- **datasets** (Optional[List[str]]): List of dataset names to process. Dataset names are resolved to datasets owned by the authenticated user.
- **dataset_ids** (Optional[List[UUID]]): List of existing dataset UUIDs to process. UUIDs allow processing of datasets not owned by the user (if permitted).
- **run_in_background** (Optional[bool]): Whether to execute processing asynchronously. Defaults to False (blocking).
- **custom_prompt** (Optional[str]): Custom prompt for entity extraction and graph generation. If provided, this prompt will be used instead of the default prompts for knowledge graph extraction.
- **ontology_key** (Optional[List[str]]): Reference to one or more previously uploaded ontology files to use for knowledge graph construction.

## Response
- **Blocking execution**: Complete pipeline run information with entity counts, processing duration, and success/failure status
- **Background execution**: Pipeline run metadata including pipeline_run_id for status monitoring via WebSocket subscription

## Error Codes
- **400 Bad Request**: When neither datasets nor dataset_ids are provided, or when specified datasets don't exist
- **409 Conflict**: When processing fails due to system errors, missing LLM API keys, database connection failures, or corrupted content

## Example Request
```json
{
    "datasets": ["research_papers", "documentation"],
    "run_in_background": false,
    "custom_prompt": "Extract entities focusing on technical concepts and their relationships. Identify key technologies, methodologies, and their interconnections.",
    "ontology_key": ["medical_ontology_v1"]
}
```

## Notes
To cognify data in datasets not owned by the user and for which the current user has write permission,
the dataset_id must be used (when ENABLE_BACKEND_ACCESS_CONTROL is set to True).

## Next Steps
After successful processing, use the search endpoints to query the generated knowledge graph for insights, relationships, and semantic search.



## OpenAPI

````yaml /cognee_openapi_spec.json post /api/v1/cognify
openapi: 3.1.0
info:
  title: Cognee API
  description: Cognee API with Bearer token and Cookie auth
  version: 1.0.0
servers:
  - url: https://api.cognee.ai
    description: Production server (full functionality)
  - url: http://localhost:8000
    description: Local development server (requires local setup)
security:
  - BearerAuth: []
  - ApiKeyAuth: []
tags:
  - name: activity
    description: ''
  - name: add
    description: Data ingestion endpoints for adding text, files, and structured data.
  - name: auth
    description: >-
      Authentication endpoints for user registration, login, and token
      management.
  - name: checks
    description: ''
  - name: cognify
    description: >-
      Knowledge processing endpoints to transform raw data into knowledge
      graphs.
  - name: configuration
    description: ''
  - name: datasets
    description: Dataset management endpoints for listing, creating, and deleting datasets.
  - name: delete
    description: Data deletion endpoints (deprecated — use datasets endpoints instead).
  - name: forget
    description: ''
  - name: health
    description: ''
  - name: improve
    description: ''
  - name: llm
    description: ''
  - name: memify
    description: ''
  - name: notebooks
    description: ''
  - name: ontologies
    description: ''
  - name: permissions
    description: Permission management for multi-user access control.
  - name: recall
    description: ''
  - name: remember
    description: ''
  - name: responses
    description: Response generation endpoints using the knowledge graph.
  - name: search
    description: Search endpoints for querying the knowledge graph.
  - name: sessions
    description: ''
  - name: settings
    description: Configuration endpoints for managing Cognee settings.
  - name: sync
    description: ''
  - name: update
    description: ''
  - name: users
    description: User management endpoints.
  - name: visualize
    description: Graph visualization endpoints.
paths:
  /api/v1/cognify:
    post:
      tags:
        - cognify
      summary: Cognify
      description: >-
        Transform datasets into structured knowledge graphs through cognitive
        processing.


        This endpoint is the core of Cognee's intelligence layer, responsible
        for converting

        raw text, documents, and data added through the add endpoint into
        semantic knowledge graphs.

        It performs deep analysis to extract entities, relationships, and
        insights from ingested content.


        ## Processing Pipeline

        1. Document classification and permission validation

        2. Text chunking and semantic segmentation

        3. Entity extraction using LLM-powered analysis

        4. Relationship detection and graph construction

        5. Vector embeddings generation for semantic search

        6. Content summarization and indexing


        ## Request Parameters

        - **datasets** (Optional[List[str]]): List of dataset names to process.
        Dataset names are resolved to datasets owned by the authenticated user.

        - **dataset_ids** (Optional[List[UUID]]): List of existing dataset UUIDs
        to process. UUIDs allow processing of datasets not owned by the user (if
        permitted).

        - **run_in_background** (Optional[bool]): Whether to execute processing
        asynchronously. Defaults to False (blocking).

        - **custom_prompt** (Optional[str]): Custom prompt for entity extraction
        and graph generation. If provided, this prompt will be used instead of
        the default prompts for knowledge graph extraction.

        - **ontology_key** (Optional[List[str]]): Reference to one or more
        previously uploaded ontology files to use for knowledge graph
        construction.


        ## Response

        - **Blocking execution**: Complete pipeline run information with entity
        counts, processing duration, and success/failure status

        - **Background execution**: Pipeline run metadata including
        pipeline_run_id for status monitoring via WebSocket subscription


        ## Error Codes

        - **400 Bad Request**: When neither datasets nor dataset_ids are
        provided, or when specified datasets don't exist

        - **409 Conflict**: When processing fails due to system errors, missing
        LLM API keys, database connection failures, or corrupted content


        ## Example Request

        ```json

        {
            "datasets": ["research_papers", "documentation"],
            "run_in_background": false,
            "custom_prompt": "Extract entities focusing on technical concepts and their relationships. Identify key technologies, methodologies, and their interconnections.",
            "ontology_key": ["medical_ontology_v1"]
        }

        ```


        ## Notes

        To cognify data in datasets not owned by the user and for which the
        current user has write permission,

        the dataset_id must be used (when ENABLE_BACKEND_ACCESS_CONTROL is set
        to True).


        ## Next Steps

        After successful processing, use the search endpoints to query the
        generated knowledge graph for insights, relationships, and semantic
        search.
      operationId: cognify_api_v1_cognify_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CognifyPayloadDTO'
            example:
              datasets:
                - main_dataset
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Cognify Api V1 Cognify Post
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    CognifyPayloadDTO:
      properties:
        datasets:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Datasets
        datasetIds:
          anyOf:
            - items:
                type: string
                format: uuid
              type: array
            - type: 'null'
          title: Datasetids
          examples:
            - []
        runInBackground:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Runinbackground
          default: false
        graphModel:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Graphmodel
          examples:
            - {}
        customPrompt:
          anyOf:
            - type: string
            - type: 'null'
          title: Customprompt
          description: Custom prompt for entity extraction and graph generation
          default: ''
        ontologyKey:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Ontologykey
          description: Reference to one or more previously uploaded ontologies
          examples:
            - []
        chunksPerBatch:
          anyOf:
            - type: integer
            - type: 'null'
          title: Chunksperbatch
          description: >-
            Number of chunks to process per task batch in Cognify (overrides
            default).
          examples:
            - 10
            - 20
            - 50
            - 100
      type: object
      title: CognifyPayloadDTO
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
      type: object
      required:
        - error
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

````