> For the complete documentation index, see [llms.txt](https://docs.oomus.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oomus.org/api-reference/dhis2.md).

# DHIS2

This section documents Oomus CampaignID's DHIS2 integration endpoints.

**Base URL:** `https://api.oomus.health`\
**Authentication:** All endpoints require `Authorization: Bearer <TOKEN>`

***

## POST /dhis2/config

Configures the DHIS2 connection for the authenticated account.

**Request body:**

```json
{
  "url": "https://dhis2.sante.gov.sn",
  "username": "oomus_readonly",
  "password": "MotDePasseDHIS2"
}
```

**200 OK response:**

```json
{
  "config_id": "dhis2cfg_01HXYZ",
  "url": "https://dhis2.sante.gov.sn",
  "username": "oomus_readonly",
  "status": "configured",
  "created_at": "2026-05-15T09:00:00Z"
}
```

> The password is stored encrypted and is never returned in API responses.

***

## POST /dhis2/test-connection

Tests the connection to the configured DHIS2 instance.

**Request body:**

```json
{
  "url": "https://dhis2.sante.gov.sn",
  "username": "oomus_readonly",
  "password": "MotDePasseDHIS2"
}
```

**200 OK response:**

```json
{
  "status": "connected",
  "dhis2_version": "2.41.2",
  "server_date": "2026-05-15T09:00:00",
  "programmes_available": 7,
  "organisation_units": 248
}
```

**401 response:**

```json
{
  "status": "auth_failed",
  "error": "Invalid DHIS2 credentials."
}
```

**503 response:**

```json
{
  "status": "unreachable",
  "error": "DHIS2 instance inaccessible from Oomus servers."
}
```

***

## GET /dhis2/preview-enrollments

Previews the enrollments available in a DHIS2 program.

**Query parameters:**

| Parameter       | Type    | Required | Description                         |
| --------------- | ------- | -------- | ----------------------------------- |
| `programme_uid` | string  | Yes      | UID of the DHIS2 program            |
| `org_unit`      | string  | No       | Filter by organizational unit       |
| `from_date`     | date    | No       | Start date (ISO 8601)               |
| `to_date`       | date    | No       | End date (ISO 8601)                 |
| `limit`         | integer | No       | Number of enrollments (default: 10) |

**200 OK response:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "programme_name": "National Vaccination Program",
  "total_enrollments": 12450,
  "preview": [
    {
      "enrollment_id": "xyz123abc",
      "enrollment_date": "2026-01-15",
      "org_unit_name": "Plateau Health Center",
      "attributes": {
        "MMD_PER_NAM": "Aminata",
        "MMD_PER_LST": "Diallo",
        "MMD_PER_DOB": "1995-03-15"
      }
    }
  ]
}
```

***

## POST /dhis2/assign-codes

Configures the mapping of DHIS2 attributes to Oomus card fields.

**Request body:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "mappings": [
    {
      "dhis2_attribute_code": "MMD_PER_NAM",
      "card_field": "first_name"
    },
    {
      "dhis2_attribute_code": "MMD_PER_LST",
      "card_field": "last_name"
    },
    {
      "dhis2_attribute_code": "MMD_PER_DOB",
      "card_field": "date_of_birth"
    },
    {
      "dhis2_attribute_code": "MMD_PER_SEX",
      "card_field": "gender"
    },
    {
      "dhis2_attribute_display_name": "Phone Number",
      "card_field": "phone_number"
    }
  ]
}
```

**200 OK response:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "mappings_configured": 5,
  "unmapped_card_fields": ["health_center", "zone"],
  "updated_at": "2026-05-15T09:15:00Z"
}
```

***

## POST /dhis2/generate-cards

Starts card generation for the enrollments of a DHIS2 program.

**Request body:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "template": "pulse",
  "dpi": 300,
  "include_mpi_id": true,
  "enrollment_filter": {
    "enrollment_date_from": "2026-01-01",
    "enrollment_date_to": "2026-05-15",
    "org_unit": "DiszpKrYNg8",
    "enrollment_status": "ACTIVE"
  }
}
```

| Field               | Type    | Required | Description                                                                                                                                      |
| ------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `programme_uid`     | string  | Yes      | UID of the DHIS2 program                                                                                                                         |
| `template`          | string  | Yes      | `vital`, `emerald`, `pulse`, `mothercare`, `shield`, `nomad`, `aero`, `horizon`, `aurora`, `sovereign`                                           |
| `dpi`               | integer | No       | 300, 450 or 600 (default: 300)                                                                                                                   |
| `include_mpi_id`    | boolean | No       | Include the MPI ID on the card (default: `true`)                                                                                                 |
| `enrollment_filter` | object  | No       | Filters on enrollments to process                                                                                                                |
| `sovereign_config`  | object  | No       | For the `sovereign` template only: `{"accent_hex": "#D4AF37", "bg_hex": "#0D1B2A", "bg_deep_hex": "#060E1A", "font_scale": 1.0, "max_attrs": 4}` |

**202 Accepted response:**

```json
{
  "task_id": "task_dhis2_01HXYZ",
  "programme_uid": "P3jJH5Tu5VC",
  "status": "pending",
  "estimated_cards": 1250,
  "created_at": "2026-05-15T09:20:00Z"
}
```

***

## GET /dhis2/tasks/{task\_id}

Returns the status of a DHIS2 generation task.

**200 OK response:**

```json
{
  "task_id": "task_dhis2_01HXYZ",
  "programme_uid": "P3jJH5Tu5VC",
  "status": "generating",
  "progress": 72,
  "cards_generated": 900,
  "total_cards": 1250,
  "mpi_resolved": 850,
  "mpi_created": 50,
  "mpi_pending_review": 12,
  "eta_seconds": 45,
  "started_at": "2026-05-15T09:20:05Z"
}
```

***

## GET /dhis2/preview-card-png

Generates a PNG preview of a card with the real data from a DHIS2 enrollment.

**Query parameters:**

| Parameter       | Type    | Required | Description                                                                                            |
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------ |
| `enrollment_id` | string  | Yes      | UID of the DHIS2 enrollment                                                                            |
| `template`      | string  | Yes      | `vital`, `emerald`, `pulse`, `mothercare`, `shield`, `nomad`, `aero`, `horizon`, `aurora`, `sovereign` |
| `dpi`           | integer | No       | 300, 450 or 600 (default: 300)                                                                         |

**200 OK response:** PNG image (Content-Type: `image/png`)

```bash
curl -X GET "https://api.oomus.health/dhis2/preview-card-png?enrollment_id=xyz123&template=pulse&dpi=300" \
  -H "Authorization: Bearer <VOTRE_TOKEN>" \
  --output apercu_carte.png
```

***

## POST /dhis2/sync-schedule

Configures the automatic synchronization schedule.

**Request body:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "interval_minutes": 30,
  "enabled": true,
  "auto_generate_cards": false
}
```

Values of `interval_minutes` : `10`, `15`, `30`, `60`, `180`

**200 OK response:**

```json
{
  "programme_uid": "P3jJH5Tu5VC",
  "interval_minutes": 30,
  "enabled": true,
  "next_sync": "2026-05-15T09:50:00Z",
  "auto_generate_cards": false
}
```

***

## POST /dhis2/send-card

Sends a generated card to a beneficiary via WhatsApp or SMS.

**Request body:**

```json
{
  "enrollment_id": "xyz123abc",
  "channel": "whatsapp",
  "phone_number": "+221771234567",
  "message": "Hello {first_name}, here is your vaccination card. Keep this message."
}
```

Values of `channel` : `whatsapp`, `sms`

**200 OK response:**

```json
{
  "enrollment_id": "xyz123abc",
  "channel": "whatsapp",
  "status": "sent",
  "message_id": "meta_msg_01HXYZ",
  "sent_at": "2026-05-15T09:25:00Z"
}
```

***

## GET /dhis2/google-wallet/{enrollment\_id}

Generates a Google Wallet link for a DHIS2 enrollment.

**200 OK response:**

```json
{
  "enrollment_id": "xyz123abc",
  "wallet_url": "https://pay.google.com/gp/v/save/eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "jwt_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "valid_until": "2027-05-15T00:00:00Z"
}
```

***

## POST /dhis2/google-wallet/bulk

Generates Google Wallet links for multiple enrollments (max 100 per request).

**Request body:**

```json
{
  "enrollment_ids": ["xyz123abc", "def456ghi", "jkl789mno"],
  "programme_uid": "P3jJH5Tu5VC"
}
```

**200 OK response:**

```json
{
  "batch_id": "batch_01HXYZ",
  "total": 3,
  "processed": 3,
  "wallet_links": [
    {
      "enrollment_id": "xyz123abc",
      "wallet_url": "https://pay.google.com/gp/v/save/eyJhbGci..."
    },
    {
      "enrollment_id": "def456ghi",
      "wallet_url": "https://pay.google.com/gp/v/save/eyJhbGci..."
    }
  ]
}
```

***

## Next steps

* [DHIS2 integration guide](/integrations/dhis2.md) — Step-by-step guide
* [DHIS2 integration — Features](/features/dhis2-integration.md)
* [Multichannel distribution](/features/distribution.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.oomus.org/api-reference/dhis2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
