> ## Documentation Index
> Fetch the complete documentation index at: https://www.help.creatora.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> When building or modifying an integration with the Creatora API, start with https://www.help.creatora.io/en/api/build-with-ai.md. Retrieve the current GraphQL SDL from https://api.creatora.io/sdl before relying on API schema information.

# Explain Students’ Course access sources

> Separate paid acquisitions, free claims and direct Course grants.

Explain why each current Student has access to a Course. This helps distinguish free acquisitions and direct grants from paid purchases.

## Request

<RequestExample>
  ```graphql theme={null}
  {
    courseById(courseId: "22222222-2222-4222-8222-222222222222") {
      id name
      aggregatedStats { studentsOwningCourse {
        id fullName email
        coursesOwned {
          id ownershipGrantSources {
            sourceName grantedOn
            offerAcquisition {
              source acquiredOn offerSnapshot { name }
              order { id status amountNetCharge }
            }
          }
        }
      } }
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Illustrative response theme={null}
  {
    "data": {
      "courseById": {
        "id": "22222222-2222-4222-8222-222222222222",
        "name": "Drawing Essentials",
        "aggregatedStats": {
          "studentsOwningCourse": [
            {
              "id": "33333333-3333-4333-8333-333333333333",
              "fullName": "Jamie Smith",
              "email": "student@example.com",
              "coursesOwned": [
                {
                  "id": "22222222-2222-4222-8222-222222222222",
                  "ownershipGrantSources": [
                    {
                      "sourceName": "administrator",
                      "grantedOn": 1788220800000,
                      "offerAcquisition": null
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  }
  ```
</ResponseExample>

## Use the result

```javascript theme={null}
const course = response.data.courseById;
const rows = course.aggregatedStats.studentsOwningCourse.map(student => ({
  studentId: student.id, email: student.email,
  sources: (student.coursesOwned.find(item => item.id === course.id)?.ownershipGrantSources ?? []).map(grant => ({
    source: grant.sourceName, grantedOn: grant.grantedOn,
    acquisitionSource: grant.offerAcquisition?.source ?? null,
    offer: grant.offerAcquisition?.offerSnapshot.name ?? null,
    orderId: grant.offerAcquisition?.order?.id ?? null,
    orderStatus: grant.offerAcquisition?.order?.status ?? null,
    amountCharged: grant.offerAcquisition?.order?.amountNetCharge ?? null
  }))
}));
```

One Student may have several access sources. Free claims and direct grants can provide access without an Order. The report shows current grants; a full access history also needs records of removed grants.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.