---
updatedAt: 2026-08-05T21:54:58.000Z
agentTools:
  projectIndex: https://developers.7shifts.com/llms.txt
---

# OAuth Authentication

<Callout icon="📘" theme="info">
  OAuth clients are issued only to vetted 7shifts partners. If you are building against your own company's 7shifts data, you do not need an OAuth client, use an access token instead. Access tokens are self-serve and take minutes to set up.

  This guide is for partners who already have an OAuth client. To learn how partnership works, see Authentication.
</Callout>

This guide covers the OAuth 2.0 client credentials flow used by 7shifts partner integrations.

## How OAuth differs from access tokens

If you've used access tokens before, three things change:

1. **Tokens are short-lived**. OAuth bearer tokens expire after 1 hour. Access tokens don't expire.
2. **Every request needs an&#x20;**`x-company-guid`**&#x20;header**. See Understanding the company GUID below.
3. **Each customer must explicitly grant your app access** before you can call the API on their behalf.

## Prerequisites

You need an OAuth client, which is issued during partner onboarding. To create one, 7shifts needs:

* A technical email contact — a valid address not tied to an individual user account
* First and last name of the primary technical contact
* Your official company name, shown to customers during authorization
* A PNG of your company logo, shown to customers during authorization
* A callback URL, used to receive the company GUID after a grant is approved

You'll receive a **client ID** and **client secret**. Store the secret securely as it cannot be recovered. Resetting a client requires re-authorizing every customer you've already integrated with.

## Understanding the company GUID

This is the most challenging concept of this auth flow, please review carefuly.

Your OAuth token is issued to your client, not to a customer. On its own, a token doesn't identify whose data you're asking for and it could be used for any company that has granted your client access.

The **company GUID** is that link. It's created when a specific customer grants your OAuth client access to their account, and it maps 1:1 to a company.

You send it on every request:

`x-company-guid: {GUID}`

This matters because some endpoints don't take a `company_id` in the path or query string. For those, the **GUID** is the only thing scoping the request to the right company's data.

Access tokens never use this header. An access token is already bound to a single company.

## The OAuth flow

The client credentials flow lets your application authenticate directly with the 7shifts API with minimal user interaction, requiring only an authorization grant.

![](https://files.readme.io/5396382-OAuth_Grant_flow.png "OAuth Grant flow.png")

### Step 1: The customer grants your client access

Before you can access a customer's data, a company administrator on their account must authorize your OAuth client. Send them to:

```text
https://app.7shifts.com/generate_token?client_id={CLIENT_ID}
```

We recommend surfacing this link on your platform's Integrations or Marketplace page.

To protect against CSRF, or to carry your own identifier through the flow, include a `state` parameter. It's an arbitrary string returned to your redirect URL when the grant is created:

```text
https://app.7shifts.com/generate_token?client_id={CLIENT_ID}&state={PARTNER_PROVIDED_STRING}
```

### Step 2: What the administrator sees

1. If not already signed in, the admin logs in to 7shifts.

![](https://files.readme.io/f83742c-Login.png "Login.png")

2. If they administer multiple companies, they choose which one to grant access to.

![](https://files.readme.io/c03a4fa-Choose_Account.png "Choose Account.png")

3. They see your company logo and name, and choose to grant access.

![](https://files.readme.io/42feab4-Grant_access_box.png "Grant access box.png")

4. On approval, a grant GUID is created.

### Step 3: Receiving the GUID

Without a redirect URL configured, the customer sees a page displaying the GUID, which they copy and send to you manually. This is the simpler setup for testing, since you don't need a handler yet.

![](https://files.readme.io/0dcc325-Screen_Shot_2022-01-25_at_1.06.56_PM.png "Screen Shot 2022-01-25 at 1.06.56 PM.png")

With a redirect URL configured, the customer is redirected to your URL with the GUID and company ID attached:

```text
https://redirect_url?guid={GUID}&company_id={COMPANY_ID}#guid={GUID}&company_id={COMPANY_ID}
```

If you passed a `state parameter`, it's appended:

```text
https://redirect_url?guid={GUID}&company_id={COMPANY_ID}&state={PARTNER_PROVIDED_STRING}#guid={GUID}&company_id={COMPANY_ID}
```

Handle the redirect by confirming completion to the customer, or by sending them to any further configuration you need.

To add a redirect URL to your client, contact 7shifts support.

A company admin can also retrieve the GUID later under **Company Settings** → **Developer Tools** → **Connected Apps**, using the "Copy the GUID to the clipboard" action.

![](https://files.readme.io/aecf55c-image.png)

### Step 4: Request a token

Request:

```curl
curl --request POST --url 'https://app.7shifts.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={CLIENT_ID}' \
--data-urlencode 'client_secret={CLIENT_SECRET}' \
--data-urlencode 'scope={SCOPES}'
```

Response:

```json
{
  "token_type": "Bearer",
  "expires_in": 3600,
  "access_token": "{ISSUED_TOKEN}"
}
```

<Callout icon="📘" theme="info">
  **Scopes are declared by you, not enforced per client**. 7shifts does not restrict which scopes your client may request at this time. The scopes you name limit that specific token, so requesting only what you need is a safeguard you apply to your own integration.
</Callout>

<Table align={["left","left"]}>
  <thead>
    <tr>
      <th>
        Scopes
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        companies:read
        companies:write
      </td>

      <td>
        Reading or mutating company object
      </td>
    </tr>

    <tr>
      <td>
        departments:read<br />departments:write
      </td>

      <td>
        Reading or mutating departments
      </td>
    </tr>

    <tr>
      <td>
        locations:read<br />locations:write
      </td>

      <td>
        Reading or mutating locations
      </td>
    </tr>

    <tr>
      <td>
        roles:read<br />roles:write
      </td>

      <td>
        Reading or mutating roles
      </td>
    </tr>

    <tr>
      <td>
        users:read<br />users:write
      </td>

      <td>
        Reading or mutating users
      </td>
    </tr>

    <tr>
      <td>
        sales:read<br />sales:write
      </td>

      <td>
        Reading or mutating sales
      </td>
    </tr>

    <tr>
      <td>
        shifts:read<br />shifts:write
      </td>

      <td>
        Reading or mutating shifts and schedule publishing
      </td>
    </tr>

    <tr>
      <td>
        time_punches:read<br />time_punches:write
      </td>

      <td>
        Reading or mutating time punches
      </td>
    </tr>

    <tr>
      <td>
        events:read<br />events:write
      </td>

      <td>
        Reading or mutating schedule events
      </td>
    </tr>
  </tbody>
</Table>

### Step 5: Verify

```curl
curl --request --url GET 'https://api.7shifts.com/v2/whoami' \
--header 'x-company-guid: {GUID}' \
--header 'Authorization: Bearer {ISSUED_TOKEN}'
```

A successful response includes an `identity_id`.

Response:

```json
{
    "data": {
        "identity_id": 123456,
        "users": [
            {
                "id": 555, ...
            }
        ]
    },
    "object": "whoami"
}
```

### Step 6: Make requests

Every request needs both headers:

```curl
url --request GET --url 'https://api.7shifts.com/v2/companies' \
--header 'x-company-guid: {GUID}' \
--header 'Authorization: Bearer {ISSUED_TOKEN}'
```

## Token expiry

Tokens expire 1 hour after creation. Request a new one using the same call in Step 4. There is currently no refresh token mechanism; one is planned.

## Revoking Grants Notifications

A company administrator can disconnect your integration at any time under **Company Settings → Developer Tools → Connected Apps.**

![](https://files.readme.io/7778bc3-image.png)

Subscribe to the   [authorization.revoked](https://developers.7shifts.com/docs/authorizationrevoked) webhook to be notified immediately when a grant is revoked, so you can stop making requests for that company.