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

# Add Patients to Cohort

> Bulk assign multiple patients to a cohort.

For more information, see the [guide about Cohorts](/medical-api/handling-data/cohorts)

## Path Params

<ParamField path="id" type="string" required>
  The ID of the cohort to assign patients to.
</ParamField>

## Body

You must provide either `patientIds` or `allPatients`, but not both.

<ParamField body="patientIds" type="string[]" optional>
  Array of patient IDs to assign to the cohort. Mutually exclusive with the `allPatients` property.
</ParamField>

<ParamField body="allPatients" type="boolean" optional>
  Property to confirm you want to assign all patients in your metriport
  instance to the cohort. Mutually exclusive with the `patientIds` array.
</ParamField>

## Response

<Snippet file="cohort-with-details-response-with-message.mdx" />

<ResponseExample>
  ```javascript Metriport SDK theme={null}
  import { MetriportMedicalApi } from "@metriport/api-sdk";

  const metriport = new MetriportMedicalApi("YOUR_API_KEY");

  // Add specific patients to cohort
  const cohortWithPatients = await metriport.addPatientsToCohort({
    cohortId: "00000000-0000-0000-0000-000000000000",
    patientIds: [
      "11111111-1111-1111-1111-111111111111",
      "22222222-2222-2222-2222-222222222222"
    ]
  });

  // Add all patients to cohort
  const cohortWithAllPatients = await metriport.addPatientsToCohort({
    cohortId: "00000000-0000-0000-0000-000000000000",
    allPatients: true
  });
  ```
</ResponseExample>

<Snippet file="cohort-add-patients-response-json.mdx" />
