# Add a service account to an organization or department

## Overview

[Video: Add a service account to an organization or department](https://www.youtube.com/watch?v=fptz3BCT1yM)

This flow describes how to give an existing [service account](https://docs.ohc.network/concepts/access-governance/service-account.md) a role in a government organization or a department. The role gives the service account access there.

## Pre-requisites

* The service account exists in Care. It can be a service account that another person created. To create one, see [Create a service account](https://docs.ohc.network/flows/access-governance/service-account/create-service-account.md).
* The service account is not already in this place. It is also not in an organization or a department above or below this place.
* If you add the service account to a government organization, the organization is on the **Governance** tab of your dashboard. It can also be a sub-organization of an organization on that tab.
* If you add the service account to a department, you are a member of a department of that facility.
* You have the permissions listed below.

## Permissions

| Permission | Access |
| - | - |
| Can Manage Users in an Organization | Shows **Link Service Account** in a government organization, and lets you save the link. Hold it in the organization or a parent organization. By default, the Administrator role holds it in a government organization. |
| Can Manage Users in a Facility Organization | Lets you add the service account to a department. Hold it in that department, a department above it, or the root department of the facility. By default, the Facility Admin and Administrator roles hold it. |
| Can List Users in an Organizations | Opens the **Service accounts** tab of a government organization. Hold it in the organization or a parent organization. By default, the Volunteer, Doctor, Nurse, Staff and Administrator roles hold it in a government organization. |
| Can View Facility Organizations | Lets you see the departments of the facility and open one. Hold it in any department of the facility. To open the root department of the facility, hold it in the root department. By default, the Facility Admin, Administrator, Staff, Doctor, Nurse and Volunteer roles hold it. |
| Can List Users in a Facility Organizations | Opens the **Service accounts** list of a department. Hold it in any department of the facility. By default, the Facility Admin, Administrator, Staff, Doctor and Nurse roles hold it. |

The role that you give must not have a permission that your own roles there do not have.

* In a government organization, Care counts your roles in the organization and its parent organizations.
* In a department, Care counts your roles in the department, the departments above it and the root department.

## Steps

### 1. Open the Service accounts tab

Open the **Service accounts** tab of the place where you want to add the service account.

* For a government organization, select the **Governance** tab on your dashboard. Select the card of the organization. Select the **Service accounts** tab.
* For a sub-organization, open its parent organization first. On the **Organizations** tab, select the sub-organization. Select its **Service accounts** tab.
* For a department, open the facility from the **Facilities** tab of your dashboard. Select **Settings**. Select **Departments**. Open the department. Select the **Service accounts** tab.

Note: In a government organization, Care shows the row of tabs only when more than one tab is available to you.

![The Care screen at the step: Open the Service accounts tab](/assets/images/link-service-account-1-0bac79e2540af8ab74354e8c01e77513.webp)

### 2. Start the link

Select **Link Service Account**.

* In a government organization, Care opens **Link Service Account to Organization**.
* In a department, Care opens **Link Service Account to Facility**.

If you do not see **Link Service Account**, you do not have permission to manage the users of this place.

![The Care screen at the step: Start the link](/assets/images/link-service-account-2-156b389fd2741030e8303291c952394c.webp)

### 3. Find the service account

Search for the service account by its first name, last name or username.

In a government organization, select **Search for service account** to open the search.

Type in **Search**.

The search shows every service account in Care. It is not limited to the service accounts that you created or the ones in your organization.

Select the service account in the results.

![The Care screen at the step: Find the service account](/assets/images/link-service-account-3-37cde9fa345082ace8abbd3bfb6b738d.webp)

### 4. Select the role

In **Select Role**, select a role for the service account. To filter the list, type in **Search Roles**.

Each role in the list shows its name and, if it has one, its description.

By default, the list has these roles:

* In a government organization: Volunteer, Doctor, Nurse, Staff and Administrator.
* In a department: Volunteer, Doctor, Nurse, Staff, Pharmacist, Administrator and Facility Admin.

Roles that your deployment adds for that place also show in the list.

Note: Care accepts only a role whose permissions you also have there. For example, if your only role there is Administrator, Care accepts only the Administrator or Volunteer role. A Facility Admin can give any of the default department roles.

![The Care screen at the step: Select the role](/assets/images/link-service-account-4-2159615c78c820fa1ec766bb7ecc08a2.webp)

### 5. Save the link

* In a government organization, select **Link to Organization**. Care shows **User added to organization successfully**.
* In a department, select **Add to Organization**. Care shows **Service account added to organization successfully**.

In a government organization, the button stays disabled until you select a service account and a role.

Care refuses the link if the service account is already in this place. Care also refuses it if the service account is in an organization or a department above or below this place.

Care also refuses the link if you cannot manage the users of this place, or if the role has a permission that you do not have.

![The Care screen at the step: Save the link](/assets/images/link-service-account-5-02eb7dc0307c0c7b07de2efd932a5aea.webp)

## Expected Outcome

* The service account has the role in the government organization or the department.
* The service account shows in the **Service accounts** list of that place. In a government organization, the list shows its role.

## Related

Concepts:

* [Service account](https://docs.ohc.network/concepts/access-governance/service-account.md)
* [Roles and Permission](https://docs.ohc.network/concepts/access-governance/access-control.md)
* [Organisation](https://docs.ohc.network/concepts/access-governance/organization.md)
* [Department](https://docs.ohc.network/concepts/facility/department.md)

Flows:

* [Create a service account](https://docs.ohc.network/flows/access-governance/service-account/create-service-account.md)
* [Change a service account's role or remove it](https://docs.ohc.network/flows/access-governance/service-account/change-or-remove-service-account.md)
* [Generate a token for a service account](https://docs.ohc.network/flows/access-governance/service-account/generate-service-account-token.md)
* [Assign a role to a user](https://docs.ohc.network/flows/access-governance/access-control/assign-role-to-user.md)
* [Add users to a department](https://docs.ohc.network/flows/facility/department/add-users-to-department.md)
