DHIS2 Cohorts API

The cohorts API from DHIS2 — 4 operation(s) for cohorts.

GitHub OpenAPI

Operations 9

GET /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id} Cohorts v1 courses cohorts read #
POST /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id} Cohorts v1 courses cohorts create #
PATCH /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id} Cohorts v1 courses cohorts partial update #
GET /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id}/users/{username} Cohorts v1 courses cohorts users read #
POST /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id}/users/{username} Cohorts v1 courses cohorts users create #
DELETE /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id}/users/{username} Cohorts v1 courses cohorts users delete #
POST /cohorts/v1/courses/{course_key_string}/users Cohorts v1 courses users create #
GET /cohorts/v1/settings/{course_key_string} Cohorts v1 settings read #
PUT /cohorts/v1/settings/{course_key_string} Cohorts v1 settings update #

Specifications

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/dhis2:dhis2-cohorts-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

dhis2-cohorts-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Open edX Cohorts API
  description: APIs for access to Open edX information
  contact:
    email: contact@academy.dhis2.org
  version: v1
servers:
- url: https://academy.dhis2.org/api
security:
- Basic: []
tags:
- name: Cohorts
paths:
  /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id}:
    parameters:
    - name: course_key_string
      in: path
      required: true
      schema:
        type: string
    - name: cohort_id
      in: path
      required: true
      schema:
        type: string
    get:
      operationId: cohorts_v1_courses_cohorts_read
      description: Endpoint to get either one or all cohorts.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
      tags:
      - Cohorts
      summary: Cohorts v1 courses cohorts read
      x-summary-source: derived
    post:
      operationId: cohorts_v1_courses_cohorts_create
      description: Endpoint to create a new cohort, must not include cohort_id.
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
      tags:
      - Cohorts
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties: {}
        required: true
      summary: Cohorts v1 courses cohorts create
      x-summary-source: derived
    patch:
      operationId: cohorts_v1_courses_cohorts_partial_update
      description: Endpoint to update a cohort name and/or assignment type.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
      tags:
      - Cohorts
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties: {}
        required: true
      summary: Cohorts v1 courses cohorts partial update
      x-summary-source: derived
  /cohorts/v1/courses/{course_key_string}/cohorts/{cohort_id}/users/{username}:
    parameters:
    - name: course_key_string
      in: path
      required: true
      schema:
        type: string
    - name: cohort_id
      in: path
      required: true
      schema:
        type: string
    - name: username
      in: path
      required: true
      schema:
        type: string
    get:
      operationId: cohorts_v1_courses_cohorts_users_read
      description: Lists the users in a specific cohort.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortUsersAPI'
      tags:
      - Cohorts
      summary: Cohorts v1 courses cohorts users read
      x-summary-source: derived
    post:
      operationId: cohorts_v1_courses_cohorts_users_create
      description: Add given users to the cohort.
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortUsersAPI'
      tags:
      - Cohorts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortUsersAPI'
        required: true
      summary: Cohorts v1 courses cohorts users create
      x-summary-source: derived
    delete:
      operationId: cohorts_v1_courses_cohorts_users_delete
      description: Removes and user from a specific cohort.
      responses:
        '204':
          description: ''
      tags:
      - Cohorts
      summary: Cohorts v1 courses cohorts users delete
      x-summary-source: derived
  /cohorts/v1/courses/{course_key_string}/users:
    parameters:
    - name: course_key_string
      in: path
      required: true
      schema:
        type: string
    post:
      operationId: cohorts_v1_courses_users_create
      description: 'View method that accepts an uploaded file (using key "uploaded-file")

        containing cohort assignments for users. This method spawns a celery task

        to do the assignments, and a CSV file with results is provided via data downloads.'
      responses:
        '201':
          description: ''
      tags:
      - Cohorts
      summary: Cohorts v1 courses users create
      x-summary-source: derived
  /cohorts/v1/settings/{course_key_string}:
    parameters:
    - name: course_key_string
      in: path
      required: true
      schema:
        type: string
    get:
      operationId: cohorts_v1_settings_read
      description: Endpoint to fetch the course cohort settings.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
      tags:
      - Cohorts
      summary: Cohorts v1 settings read
      x-summary-source: derived
    put:
      operationId: cohorts_v1_settings_update
      description: Endpoint to set the course cohort settings.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
      tags:
      - Cohorts
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties: {}
        required: true
      summary: Cohorts v1 settings update
      x-summary-source: derived
components:
  schemas:
    CohortUsersAPI:
      required:
      - username
      type: object
      properties:
        username:
          title: Username
          description: Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
          type: string
          pattern: ^[\w.@+-]+$
          maxLength: 150
          minLength: 1
        email:
          title: Email address
          type: string
          format: email
          maxLength: 254
        name:
          title: Name
          type: string
          readOnly: true
  securitySchemes:
    Basic:
      type: http
      scheme: basic