# Update Job — ServiceM8

> Update a job (loads the record, merges your fields, then POSTs). See the documentation

- Key: `servicem8-update-job`
- Type: Action (Write)
- Version: 0.0.1
- App: ServiceM8 (`servicem8`) — https://pipedream.com/apps/servicem8.md
- This page (HTML): https://pipedream.com/apps/servicem8/actions/update-job
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/servicem8/actions/update-job/update-job.mjs

## Description

Update a job (loads the record, merges your fields, then POSTs). [See the documentation](https://developer.servicem8.com/reference/updatejobs)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `uuid` | `string` | Yes | Job to load, merge, and save (search or paste UUID). Options are loaded from the connected account. |
| `createdByStaffUuid` | `string` | No | Staff member who created the job (created_by_staff_uuid). Options are loaded from the connected account. |
| `date` | `string` | No | Job date (date; e.g. YYYY-MM-DD per API). |
| `companyUuid` | `string` | No | Client/company for this job. Options are loaded from the connected account. |
| `billingAddress` | `string` | No | Invoice address (max 500). |
| `status` | `string` | Yes | Job status (max 20 characters). |
| `categoryUuid` | `string` | No | Job category. Options are loaded from the connected account. |
| `purchaseOrderNumber` | `string` | No | Client PO reference (max 100 characters). |
| `invoiceSent` | `boolean` | No | Whether an invoice has been sent (sent as 0 or 1). |
| `queueUuid` | `string` | No | Queue this job belongs to. Options are loaded from the connected account. |
| `queueExpiryDate` | `string` | No | When the job expires from the queue. |
| `queueAssignedStaffUuid` | `string` | No | Staff assigned to this job in the queue. Options are loaded from the connected account. |
| `badges` | `string[]` | No | Badge UUIDs (list badges). Sent as a JSON array string. Options are loaded from the connected account. |
| `quoteDate` | `string` | No | When status became Quote. |
| `quoteSent` | `boolean` | No | Whether a quote was sent (0 or 1). |
| `workOrderDate` | `string` | No | When status became Work Order. |
| `jobAddress` | `string` | No | Work site address (max 500 characters). |
| `jobDescription` | `string` | No | Scope or work requested. |
| `workDoneDescription` | `string` | No | Description of work completed. |
| `paymentProcessed` | `boolean` | No | Exported to accounting (0 or 1). |
| `paymentReceived` | `boolean` | No | Full payment received (0 or 1). |
| `completionDate` | `string` | No | When status became Completed. |
| `unsuccessfulDate` | `string` | No | When status became Unsuccessful. |

## 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": "servicem8",
      },
    },
  },
)

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: "servicem8-update-job",
  arguments: {
    uuid: "Job to update",
    createdByStaffUuid: "Created by staff",
  },
})
```

**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: "servicem8-update-job",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    servicem8: { authProvisionId: "apn_xxxxxxx" },
    uuid: "Job to update",
    createdByStaffUuid: "Created by staff",
  },
})

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": "servicem8-update-job",
    "configured_props": {
      "servicem8": { "authProvisionId": "apn_xxxxxxx" },
      "uuid": "Job to update",
      "createdByStaffUuid": "Created by staff"
    }
  }'
```

---

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