> For the complete documentation index, see [llms.txt](https://docs.docontrol.io/docontrol-user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docontrol.io/docontrol-user-guide/workflows/define-workflow-settings/action-settings/utilities/docontrol-api-action/api-for-offboarding-employees.md).

# API for offboarding employees

When an employee is terminated, it’s best practice to remediate all assets that were shared with the terminated employee’s personal email.&#x20;

You can define a DoControl API action to automatically remove a terminated employee’s access from all company assets.

#### To configure a DoControl API for removing access of terminated employees:

1. Create an [API key](/docontrol-user-guide/system-management/api.md#create-api-keys) in DoControl.
2. Get an [access token](/docontrol-user-guide/system-management/api.md#receive-an-access-token).
3. In the DoControl API, enter the access token in the request body:\
   `refreshToken”: “[accessToken]`<br>
4. Define the request to send in the Docontrol API:\
   `POST` [`https://apollo-gateway-v4-api.prod.docontrol.io/graphql`<br>](https://apollo-gateway-v4-api.prod.docontrol.io/graphql)`Authorization: Bearer [access token]`\
   `Body:[GraphQL query]`<br>
5. The GraphGL query returns with the personal email address of the terminated employee. Define the GraphQL query to send:

```
query MyQuery {
  hrisUsers(

    input: {filters: {primaryEmail: {single: {operator: EQUALS, value: "[Enter the organizational email address]"}}}, serviceId: "sap-successfactors"}


  ) {
    nodes {
      personalEmail
      primaryEmail
      employmentEndDate
      employmentStatus
    }
  }
}
```

6. Save the personal email address in a parameter and use it in the next query, which filters all assets that should be remediated, and then activates the relevant remediation action:&#x20;

```
mutation StartGoogleRemediationAssessment {

  startGoogleRemediationAssessment(

    input: {autoApproveInput: {remediateInherited: true, workflowId: "[remediation_workflow_ID]"}, remediationType: GOOGLE_REMOVE_COLLABORATORS, filterString: "[{\"permissionEmail\":{\"single\":{\"operator\":\"EQUALS\",\"value\":\"{[place here the saved personal email addess]\"}}},{\"ownerEmail\":{\"single\":{\"operator\":\"EQUALS\",\"value\":\"[Place here organizational email address]\"}}}]"}
  ) {
    jobId
    remediationType
    updatedAt
    executionId
  }
}

```

7. Check the remediation status. This API doesn’t have a filter. In order to get the execution status, you need to use the jobId that was received in the previous query. Run this query:

```
query MyQuery {
googleRemediationAssessment {
     nodes {
jobId
jobTypeStatus
executionId
}
         }
}

```

&#x20;

8. When you receive this status, the workflow is complete:\
   jobTypeStatus = REMEDIATION\_WORKFLOW\_DONE


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docontrol.io/docontrol-user-guide/workflows/define-workflow-settings/action-settings/utilities/docontrol-api-action/api-for-offboarding-employees.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
