# Update Order — Upsales

> Updates an existing order in Upsales. See the documentation

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

## Description

Updates an existing order in Upsales. [See the documentation](https://api.upsales.com/#eec6ead8-d121-40e6-9910-185ca06ac323)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `orderId` | `string` | Yes | The order's unique ID. Use Get Order List to find an ID. Options are loaded from the connected account. |
| `description` | `string` | No | Order description |
| `date` | `string` | No | Order date (ISO 8601 format, e.g., 2024-01-15T10:00:00Z) |
| `userId` | `string` | No | User who created the order Options are loaded from the connected account. |
| `clientId` | `string` | No | Company this order belongs to Options are loaded from the connected account. |
| `stageId` | `string` | No | Stage to which the order belongs to Options are loaded from the connected account. |
| `probability` | `integer` | No | Probability percentage, between 0-100 |
| `closeDate` | `string` | No | Date when Order became 100% or 0% (ISO 8601 format) |
| `notes` | `string` | No | Order notes |
| `contactId` | `string` | No | Contact reference of the company that ordered Options are loaded from the connected account. |
| `projects` | `object` | No | Campaign payload as a JSON object, e.g. { "id": 42, "name": "Q1 Retention" } |
| `clientConnectionId` | `string` | No | Second company connected to this order Options are loaded from the connected account. |
| `currencyRate` | `string` | No | Currency rate in relation to the base currency of the account |
| `currency` | `string` | No | Currency for the order (e.g., USD, EUR, SEK) |
| `custom` | `string[]` | No | Array of custom field/value pairs in JSON format. Each entry should be a string like { "fieldId": 1, "value": "my value" } |
| `competitorId` | `integer` | No | Competitor ID. Find competitors at https://integration.upsales.com/api/v2/competitors/ |
| `lostReason` | `integer` | No | Lost Reason ID. Find lost reasons at https://integration.upsales.com/api/v2/fieldTranslations/?type=orderlostreason |
| `notify` | `boolean` | No | Whether to notify other users in the account about this order. Default is true. |
| `orderRow` | `string[]` | No | Array of order row objects in JSON format. Each entry should be a string like { "product": { "id": 123 }, "quantity": 2, "price": 100 }. See the documentation for all available properties. |

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

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: "upsales-update-order",
  arguments: {
    orderId: "Order ID",
    description: "Description",
  },
})
```

**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: "upsales-update-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    upsales: { authProvisionId: "apn_xxxxxxx" },
    orderId: "Order ID",
    description: "Description",
  },
})

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": "upsales-update-order",
    "configured_props": {
      "upsales": { "authProvisionId": "apn_xxxxxxx" },
      "orderId": "Order ID",
      "description": "Description"
    }
  }'
```

---

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