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

# Registration for a learning path

## Register a user to a learning path

Depending on the learning path settings, users can register by themselves (only to the public trainings)
or be assigned to the learning path by administrators or managers (to any training).
In both cases the same mutation `createLpIndividualMembership` should be used.

<Note>
  If the learning path has Stripe integration enabled (i.e. has an associated Stripe product), enrollment behaves differently:
  the learner is automatically enrolled once their Stripe payment is completed, and anonymous user contexts can no longer
  self-enroll. See [Enrollment access with Stripe](/OpignoEnterpriseAPI/StripeIntegration#enrollment-access-with-stripe) for details.
</Note>

<Note>
  In case if the user is being registered to a learning path not by themselves,
  the current API user should be associated with `ADMINISTRATOR` scope.
  See more about the user context scope [here](/OpignoEnterpriseAPI/UserContextManagement).
</Note>

The mutation accepts the following arguments:

| Argument          | Type | Description                                                                                                                                               |
| :---------------- | :--- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lpId`            | `ID` | Required; ID of the learning path to register a user to.                                                                                                  |
| `userContextUuid` | `ID` | Optional in the schema. Omit for self-registration (current API user context). Pass the target user’s context UUID when a manager registers another user. |

As a result, `CreateLpIndividualMembershipResponse` object will be returned that contains the following properties:

| Property   | Type                   | Description                                               |
| :--------- | :--------------------- | :-------------------------------------------------------- |
| `errors`   | `[Violation]`          | Contains the list of validation errors, if there are any. |
| `response` | `IndividualMembership` | Represents the created membership object (see below).     |

**`IndividualMembership` object**

| Property       | Type           | Description                                                                                                                                                                                                                                         |
| :------------- | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`           | `ID`           | Required; represents the unique identifier of the membership.                                                                                                                                                                                       |
| `learningPath` | `LearningPath` | Required; the learning path associated with the membership.                                                                                                                                                                                         |
| `cta`          | `[Cta]`        | An optional list of call-to-actions (CTA) that define the allowed user interaction with the related learning path based on the created membership. The full list of learning path CTAs can be checked [here](/OpignoEnterpriseAPI/LearningPathCTA). |

Below is an example of registering a user by passing their `userContextUuid` to the learning path with ID 40:

<CodeGroup>
  ```graphql GraphQL theme={null}
  mutation createLpIndividualMembership {
    createLpIndividualMembership(lpId: 40, userContextUuid: "a1b2c3d4-e5f6-7890-abcd-ef1234567890") {
      response {
        cta {
          actionId
          arguments {
            key
            value
          }
        }
      }
    }
  }
  ```

  ```json Query result theme={null}
  {
    "data": {
      "createLpIndividualMembership": {
        "response": {
          "cta": [
            {
              "actionId": "VIEW_LP",
              "arguments": [
                {
                  "key": "lpId",
                  "value": "40"
                }
              ]
            }
          ]
        }
      }
    }
  }
  ```
</CodeGroup>

## Unenroll a user from a learning path

In general, the unenrollment process follows the same rules and behavior as enrollment:
a user can be unregistered from any previously enrolled learning path by themselves or by administrator.

In both cases `removeLpIndividualMembership` mutation should be used.
Mutation accepts the same arguments as [`createLpIndividualMembership`](/OpignoEnterpriseAPI/LearningPathRegistration#register-a-user-to-a-learning-path).

As a result, `SuccessResponse` object will be returned:

| Property   | Type          | Description                                                                            |
| :--------- | :------------ | :------------------------------------------------------------------------------------- |
| `errors`   | `[Violation]` | Contains the list of validation errors, if there are any.                              |
| `response` | `Boolean`     | If `true`, the mutation has been successfully executed and the membership was removed. |

Below is an example of mutation to unregister the **current** API user from the learning path with ID 40:

<CodeGroup>
  ```GraphQL GraphQL theme={null}
  mutation removeLpIndividualMembership {
      removeLpIndividualMembership(lpId:40) {
          errors
          response
      }
  }
  ```

  ```Query Query result theme={null}
  {
      "data": {
          "removeLpIndividualMembership": {
              "errors": [],
              "response": true
          }
      }
  }
  ```
</CodeGroup>
