# 7shifts

7shifts is a restaurant workforce management platform providing scheduling, time tracking, labor compliance, and team communication tools. The Sling 7shifts connector extracts data from the 7shifts REST API (v2), supporting companies, locations, employees, shifts, time punches, and configuration data.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](https://docs.slingdata.io/sling-cli/cli-pro) or [Platform Plan](https://docs.slingdata.io/sling-platform/platform).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `access_token` **(required)** -> Your 7shifts API v2 access token

**Inputs:**

* `company_id` **(required)** -> Your 7shifts company ID (used for child endpoints that iterate over users or locations)
* `anchor_date` (optional) -> The starting date for historical data extraction on first sync (default: 1 year ago). Format: `YYYY-MM-DD`

### Getting Your Credentials

1. Log in to your [7shifts account](https://app.7shifts.com)
2. Go to **Company Settings** > **Developer Tools** > **Access Tokens**
3. Click **Create Access Token**
4. Give the token a name (e.g., "Sling Integration")
5. Copy the generated access token
6. To find your **Company ID**, look at the URL when logged in: `https://app.7shifts.com/company/{company_id}/...`

{% hint style="warning" %}
**Important:** Store your access token securely. It provides access to your 7shifts data. Never commit tokens to version control.
{% endhint %}

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set SEVEN_SHIFTS type=api spec=7shifts secrets='{ access_token: your_token_here }' inputs='{ company_id: "123456" }'
```

{% endcode %}

### Environment Variable

{% code overflow="wrap" %}

```bash
export SEVEN_SHIFTS='{ type: api, spec: 7shifts, secrets: { access_token: "your_token_here" }, inputs: { company_id: "123456" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/sling-cli/environment#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  SEVEN_SHIFTS:
    type: api
    spec: 7shifts
    secrets:
      access_token: "your_token_here"
    inputs:
      company_id: "123456"
```

**With anchor date for historical data:**

```yaml
connections:
  SEVEN_SHIFTS:
    type: api
    spec: 7shifts
    secrets:
      access_token: "your_token_here"
    inputs:
      company_id: "123456"
      anchor_date: "2024-01-01"
```

## Replication

Here's an example replication configuration to sync 7shifts data to a PostgreSQL database:

```yaml
source: SEVEN_SHIFTS
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: seven_shifts.{stream_name}

streams:
  # Organizational structure
  companies:
    mode: incremental
  locations:
    mode: incremental
  departments:
    mode: incremental
  roles:
    mode: incremental
  users:
    mode: incremental

  # Scheduling & time tracking
  shifts:
    mode: incremental
  time_punches:
    mode: incremental

  # Settings & configuration
  labor_settings:
  log_book_categories:
  availability_reasons:
  inactive_reasons:
```

**Sync all endpoints:**

```yaml
source: SEVEN_SHIFTS
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: seven_shifts.{stream_name}

streams:
  '*':
```

## Endpoints

### Company & Organization

| Endpoint      | Description                       | Incremental           |
| ------------- | --------------------------------- | --------------------- |
| `companies`   | Companies accessible by the token | Yes (modified\_since) |
| `locations`   | Locations for each company        | Yes (modified\_since) |
| `departments` | Departments for each company      | Yes (modified\_since) |
| `roles`       | Roles for each company            | Yes (modified\_since) |

### Users & Assignments

| Endpoint           | Description                                     | Incremental           |
| ------------------ | ----------------------------------------------- | --------------------- |
| `users`            | Employees and managers                          | Yes (modified\_since) |
| `user_wages`       | Wage records for each user (child)              | No                    |
| `user_assignments` | Role/location assignments for each user (child) | No                    |

### Scheduling & Time Tracking

| Endpoint         | Description                        | Incremental           |
| ---------------- | ---------------------------------- | --------------------- |
| `shifts`         | Scheduled shifts                   | Yes (modified\_since) |
| `time_punches`   | Clock in/out records               | Yes (modified\_since) |
| `shift_feedback` | Post-shift feedback from employees | No (date-range)       |

### Sales & Receipts

| Endpoint   | Description                 | Incremental                       |
| ---------- | --------------------------- | --------------------------------- |
| `receipts` | Sales receipts per location | Yes (modified\_since, 90-day max) |

### Time Off & Availability

| Endpoint               | Description                   | Incremental |
| ---------------------- | ----------------------------- | ----------- |
| `time_off`             | Time off requests             | No          |
| `availabilities`       | Employee availability records | No          |
| `availability_reasons` | Availability reason codes     | No          |

### Events & Log Book

| Endpoint              | Description                          | Incremental     |
| --------------------- | ------------------------------------ | --------------- |
| `events`              | Schedule events (holidays, meetings) | No (date-range) |
| `log_book_categories` | Log book category definitions        | No              |
| `log_book_posts`      | Log book posts                       | No              |

### Task Management

| Endpoint                   | Description                   | Incremental |
| -------------------------- | ----------------------------- | ----------- |
| `task_management_settings` | Task management configuration | No          |
| `task_list_templates`      | Task list templates           | No          |

### Settings

| Endpoint            | Description                  | Incremental |
| ------------------- | ---------------------------- | ----------- |
| `labor_settings`    | Labor compliance settings    | No          |
| `inactive_reasons`  | Inactive status reason codes | No          |
| `day_part_settings` | Day part configuration       | No          |
| `tip_pool_settings` | Tip pool settings            | No          |

To discover available endpoints:

```bash
sling conns discover SEVEN_SHIFTS
```

## Incremental Sync

The 7shifts connector supports incremental sync for core data endpoints using `modified_since` filtering:

* **companies, locations, departments, roles, users** — Fetches records modified since the last sync
* **shifts, time\_punches** — Fetches records modified since the last sync (or `anchor_date` on first run)
* **receipts** — Fetches receipts modified since last sync (limited to 90 days lookback)

### Anchor Date

On the first sync, incremental endpoints use the `anchor_date` input (default: 1 year ago) as the starting point. The `receipts` endpoint is limited to 90 days lookback by the API.

### Child Endpoints

The `user_wages` and `user_assignments` endpoints use a queue-based pattern:

1. First, the `users` endpoint runs and collects user IDs
2. Then, child endpoints iterate through the queue to fetch data for each user

This means you should run the `users` endpoint before `user_wages` or `user_assignments` in your replication.

Similarly, `receipts` and `events` iterate over location IDs collected by the `locations` endpoint.

## Rate Limiting

The 7shifts API allows up to 600 requests per minute. The connector automatically:

* Uses conservative rate limiting (8 requests/second)
* Retries with exponential backoff on rate limit responses (HTTP 429)
* Retries on server errors (HTTP 5xx)

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).
