# Create Shift — Connecteam

> Creates a new shift in the scheduler. See the documentation

- Key: `connecteam-create-shift`
- Type: Action (Write)
- Version: 0.0.2
- App: Connecteam (`connecteam`) — https://pipedream.com/apps/connecteam.md
- This page (HTML): https://pipedream.com/apps/connecteam/actions/create-shift
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/connecteam/actions/create-shift/create-shift.mjs

## Description

Creates a new shift in the scheduler. [See the documentation](https://developer.connecteam.com/reference/create_shifts_scheduler_v1_schedulers__schedulerid__shifts_post)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `schedulerId` | `string` | Yes | The ID of the scheduler. Options are loaded from the connected account. |
| `startTime` | `string` | Yes | The start time of the shift in ISO8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ). |
| `endTime` | `string` | Yes | The end time of the shift in ISO8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ). |
| `title` | `string` | Yes | The title of the shift. |
| `timezone` | `string` | No | The timezone of the shift in Tz format (e.g. America/New_York). If not specified, it uses the timezone configured in the app settings. |
| `isPublished` | `boolean` | No | Whether the shift is published. |
| `jobId` | `string` | No | The ID of the job. Options are loaded from the connected account. |
| `locationData` | `object` | No | The location data of the shift. Example {"gps":{"address": "Address Example 123","longitude":"-12.345678","latitude":"-12.345678"},"isReferencedToJob":false}. See the documentation. |
| `assignedUserId` | `string` | No | The ID of the assigned user. Options are loaded from the connected account. |
| `notes` | `string[]` | No | Additional notes for the shift. HTML is supported. Example <p>Note example</p> See the documentation. |
| `breaks` | `string[]` | No | A list of stringified objects of breaks to create for the shift. Example {"name":"Break name example","type":"paid","startTime":123456789,"duration":123} See the documentation. |
| `isOpenShift` | `boolean` | No | Whether the shift is an open shift. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "connecteam",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "connecteam-create-shift",
  arguments: {
    schedulerId: "Scheduler ID",
    startTime: "Start Time",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "connecteam-create-shift",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    connecteam: { authProvisionId: "apn_xxxxxxx" },
    schedulerId: "Scheduler ID",
    startTime: "Start Time",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "connecteam-create-shift",
    "configured_props": {
      "connecteam": { "authProvisionId": "apn_xxxxxxx" },
      "schedulerId": "Scheduler ID",
      "startTime": "Start Time"
    }
  }'
```

---

- App: https://pipedream.com/apps/connecteam.md · All apps: https://pipedream.com/apps
