# Import Users from a CSV

Import users to your PagerDuty account from a CSV

If you would like to add users in bulk, we offer the following methods using a comma-separated value (CSV) list:

- [Import Users with a Self-Serve Ruby Script](#import-users-with-a-self-serve-ruby-script)
- [Request Help from PagerDuty Support](#request-help-from-pagerduty-support)

## Import Users with a Self-Serve Ruby Script

You can use the following Ruby script to import users on your own: 

- [ import_users.rb](https://github.com/PagerDuty/public-support-scripts/blob/master/import_users/import_users.rb)

You will need the following:

- A [general access REST API key](/account-admin/api-access-keys#generate-a-general-access-rest-api-key).
- The email address of the user making the change.
- The path to your CSV file a command-line argument. The CSV file can have any name, however the path to the file must be correct.

### Example

```ruby
ruby import_users.rb -a tKvs3QDNi84Nl326Krdz -e admin@example.com -f ./users.csv
```

The usage instructions for the tool can be found by executing the script with a `-h` or `--help` flag:

```ruby
import_users.rb -h
Usage: import_users.rb [options]
    -a, --access-token [String] Access Token
    -e, --requester-email [String] Requester Email
    -f, --csv-path [String] Path to CSV file
```

### CSV Format

The CSV file should be in the following format:

 `name,email,role,title,country code,phone number,team 1;team 2;team 3` 

- There is no need to include a header in the file, and the title and Teams fields are optional. If the user is on multiple [Teams](/account-admin/teams), separate each Team with a semicolon. 
- The script will create SMS, phone call, and email [notification rules](/account-admin/user-profile/notification-rules) using the email address and phone number provided. The notification rules will notify users immediately when they are assigned to an incident, however users can adjust these settings later on their [User Profile](/account-admin/user-profile/notification-rules). 
- The user's role can be `admin`, `user`, `limited_user`, `observer`, `restricted_access`, `read_only_user` (Full Stakeholder), or `read_only_limited_user` (Limited Stakeholder). If a role is not specified, the script defaults to `user`. To see how these values map to values on the webpage, please refer to our section on [Roles in the REST API and SAML](/account-admin/advanced-permissions#roles-in-the-rest-api-and-saml). You can find additional information on user roles and permissions in the following articles:
  - [User Roles](/account-admin/user-roles)
  - [Advanced Permissions](/account-admin/advanced-permissions)

#### Example

```
Joe User,ju@example.com,user,Operations Engineer,1,5555555555,Engineering;Operations 
Bob Dobbs,bd@example.com,admin,Director of Engineering,86,15555555554,Engineering;Operations;Leadership
```

## Request Help from PagerDuty Support

> **Required Role:** Only the Account Owner can request user import assistance from Support.
>
> If you do not not have the Account Owner [base role](/account-admin/advanced-permissions#base-roles), you can find your Account Owner by navigating to **People**  →  **Users** and set the **Base roles** filter to **Account Owner**.

If you would like to add 25 or more users, the Account Owner of your PagerDuty account can request that PagerDuty Support creates a write-scoped API Key in your account to import the users for you.

Please create a spreadsheet with the following columns, in this order:

|      |       |      |       |              |              |       |           |
| :--- | :---- | :--- | :---- | :----------- | :----------- | :---- | :-------- |
| Name | Email | Role | Title | Country Code | Phone Number | Teams | Team Role |

The following spreadsheet templates are available for your use:

- [Empty spreadsheet template with column headers ](https://docs.google.com/spreadsheets/d/1v3-KMrAOLfzQUC3GN_8qibZaIJlAHulBmRr9aHj8l9k/edit#gid=0)
- [Filled example spreadsheet, showing data formatting](https://docs.google.com/spreadsheets/d/1v3-KMrAOLfzQUC3GN_8qibZaIJlAHulBmRr9aHj8l9k/edit#gid=1056898642)

After populating a spreadsheet in this format, export it as a spreadsheet file (e.g., `.CSV`, `.XLSX`, `.NUMBERS`, etc.) and have the Account Owner [contact our Support Team](mailto:support@pagerduty.com) to request help importing the users.

### Field Details

| Field                  | Description                                                                                                                                                                                                                                                                                                                                                                          |
| :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name** (_Required_)  | First and last name.                                                                                                                                                                                                                                                                                                                                                                 |
| **Email** (_Required_) | Login email address; must be unique to this user.                                                                                                                                                                                                                                                                                                                                    |
| **Role** (_Required_)  | A valid REST API user role (`admin`, `user`, `limited_user, observer`, `restricted_access`, `read_only_user`, `read_only_limited_user`). **Note**: `read_only_user`and `read_only_limited_user` roles require Stakeholder user licenses. Read [Billing, Invoices and Payments](/account-admin/billing#stakeholder-users) for more information about Stakeholder users. |
| **Title**              | Job title.                                                                                                                                                                                                                                                                                                                                                                           |
| **Country Code**       | 1-3 digit country calling code. Please refer to [Supported Countries](/incident-management/notifications/supported-countries) for more information about valid country codes.                                                                                                                                                                                                                                       |
| **Phone Number**       | The user’s phone number where they will receive SMS and phone call notifications.                                                                                                                                                                                                                                                                                                    |
| **Teams**              | [Teams](/account-admin/teams) that the user should be added to. This can include multiple Teams separated by semicolons (`;`). If the Team does not exist, it will be created when the script runs.                                                                                                                                                                                           |
| **Team Role**          | User role that will be applied to the given Teams. Must be a valid [Team role](/account-admin/advanced-permissions#team-roles) (i.e., Responder, Observer, Manager).                                                                                                                                                                                                                          |
