---
title: "Save a new version of a workflow"
description: "Never overwrites: every save is a version, and what runs does not change until a person activates one."
canonical: "https://grid82.com/docs/app-api/my/workflows-code-set"
updated: "2026-11-13"
---

# Save a new version of a workflow

`PUT https://your-suite.grid82.app/your-app/v1/workflows/{workflowId}/code`

Never overwrites: every save is a version, and what runs does not change until a person activates one.

> **Note: Generic contract**
>
> Your own version of this operation, with your tables and the fields you can read, is in
> your app's document: `https://{suite}.grid82.app/{app}/v1/openapi.json`, behind your credential.
> [Why each person gets their own](/docs/start/studio-and-runtime#why-an-app-has-an-api-of-its-own).

Send `baseVersion` (the latest version when you read it) to be refused with 409 if somebody saved since. The answer is the compiler's verdict on this version: `ok`, every error with its line and the fix, warnings, the graph the Automations tab draws and what the workflow can touch. A version that does not compile is kept and cannot be activated: fix the errors and save again.

Requires the scopes `workflows:write`, `records:read`, `records:write`, `schema:read`. Operation `my.workflows.code.set`. MCP tool `my_workflows_code_set`. CLI: `grid82 my workflows code set` (`npx grid82`).

## Path parameters

| Name         | Type   | Required | Description |
| ------------ | ------ | -------- | ----------- |
| `workflowId` | string | yes      |             |

## Headers

| Name              | Type   | Required | Description                                                                                                                                                                                                                                                        |
| ----------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Idempotency-Key` | string | no       | Any unique string. Sending the same key with the same request again returns the first response (marked `Idempotency-Replayed: true`) instead of running it twice. Reusing it for a different request is refused with 409. Kept for 24 hours. Up to 255 characters. |

## Request body

| Field         | Type                                        | Required | Description             |
| ------------- | ------------------------------------------- | -------- | ----------------------- |
| `source`      | string                                      | yes      | Up to 65536 characters. |
| `note`        | string                                      | no       | Up to 200 characters.   |
| `via`         | "assistant" or "hand" or "api" or "restore" | no       |                         |
| `baseVersion` | integer                                     | no       | At least 0.             |

**Authorizations**

- `Authorization` (bearer, in header, required)

## Response

**200**: Success

- `data` (`object`, required)
- `data.id` (`string`, required)
- `data.version` (`integer`, required)
- `data.at` (`string`, required)
- `data.ok` (`boolean`, required)
- `data.errors` (`object[]`, required)
- `data.errors.line` (`integer`, required)
- `data.errors.message` (`string`, required)
- `data.warnings` (`object[]`, required)
- `data.warnings.line` (`integer`, required)
- `data.warnings.message` (`string`, required)
- `data.graph` (`Record<string, object> | null`)
- `data.impact` (`Record<string, object> | null`)

```json
{
  "data": {
    "id": "<string>",
    "version": 123,
    "at": "<string>",
    "ok": true,
    "errors": [
      {
        "line": 123,
        "message": "<string>"
      }
    ],
    "warnings": [
      {
        "line": 123,
        "message": "<string>"
      }
    ],
    "graph": {},
    "impact": {}
  }
}
```

**4XX**: Refused

- `error` (`object`, required)
- `error.code` (`enum<string>`, required, one of: `not_found, forbidden, unauthenticated, validation_failed, conflict, rate_limited, payment_required, not_implemented, internal`)
- `error.message` (`string`, required)
- `error.details` (`Record<string, unknown>`)

```json
{
  "error": {
    "code": "not_found",
    "message": "<string>",
    "details": {}
  }
}
```

**Example request**

```bash
curl --request PUT \
  --url 'https://your-suite.grid82.app/your-app/v1/workflows/<workflowId>/code' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "source": "<string>"
}'
```
