> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cail.health/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cail.health/_mcp/server.

# Update a pathway draft

PATCH https://staging.cail.health/v1/plan-definitions/{id}/draft
Content-Type: application/json

Updates an in-progress draft. Only the supplied fields change; everything else is preserved. Requires the client to send its current versionId in `expectedVersionId` for optimistic locking. A mismatch returns a conflict error and the client must refetch the draft before retrying. The decision tree is opaque JSON in this API; treat it as authored content the engine consumes.

Reference: https://docs.cail.health/api-references/api-reference/understand-coverage/update-draft

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: cail-api
  version: 1.0.0
paths:
  /v1/plan-definitions/{id}/draft:
    patch:
      operationId: update-draft
      summary: Update a pathway draft
      description: >-
        Updates an in-progress draft. Only the supplied fields change;
        everything else is preserved. Requires the client to send its current
        versionId in `expectedVersionId` for optimistic locking. A mismatch
        returns a conflict error and the client must refetch the draft before
        retrying. The decision tree is opaque JSON in this API; treat it as
        authored content the engine consumes.
      tags:
        - subpackage_understandCoverage
      parameters:
        - name: id
          in: path
          description: Stable identifier of the draft pathway.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The updated draft acknowledgement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateDraftPlanDefinitionResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDraftPlanDefinitionRequest'
servers:
  - url: https://staging.cail.health
    description: https://staging.cail.health
components:
  schemas:
    UpdateDraftPlanDefinitionRequest:
      type: object
      properties:
        expectedVersionId:
          type: number
          format: double
          description: >-
            Client’s current versionId for optimistic locking. A mismatch with
            the server-side row returns a conflict error and the client must
            refetch.
        title:
          type: string
          description: Updated pathway title.
        description:
          type: string
          description: Updated pathway description.
        decisionTree:
          type: object
          additionalProperties:
            description: Any type
          description: >-
            Updated decision-tree structure. Treat as opaque JSON; the shape is
            internal.
      required:
        - expectedVersionId
      title: UpdateDraftPlanDefinitionRequest
    UpdatedDraftPlanDefinitionStatus:
      type: string
      enum:
        - draft
        - active
        - retired
      description: Lifecycle status (unchanged from `draft`).
      title: UpdatedDraftPlanDefinitionStatus
    UpdatedDraftPlanDefinition:
      type: object
      properties:
        id:
          type: string
          description: Stable identifier of the updated draft.
        versionId:
          type: number
          format: double
          description: New version number assigned after the update for optimistic locking.
        status:
          $ref: '#/components/schemas/UpdatedDraftPlanDefinitionStatus'
          description: Lifecycle status (unchanged from `draft`).
        lastUpdated:
          type: string
          description: ISO 8601 timestamp of the update.
      required:
        - id
        - versionId
        - status
        - lastUpdated
      title: UpdatedDraftPlanDefinition
    UpdateDraftPlanDefinitionResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/UpdatedDraftPlanDefinition'
        message:
          type: string
          description: Human-readable acknowledgement.
      required:
        - data
        - message
      title: UpdateDraftPlanDefinitionResponse
  securitySchemes:
    auth0Bearer:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "expectedVersionId": 7
}
```

**Response**

```json
{
  "data": {
    "id": "a1b2c3d4-e5f6-4789-9abc-def012345678",
    "versionId": 8,
    "status": "draft",
    "lastUpdated": "2026-05-13T14:21:00.000Z"
  },
  "message": "Draft updated successfully"
}
```

**SDK Code**

```python Draft updated to version 8
import requests

url = "https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft"

payload = { "expectedVersionId": 7 }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Draft updated to version 8
const url = 'https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"expectedVersionId":7}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Draft updated to version 8
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft"

	payload := strings.NewReader("{\n  \"expectedVersionId\": 7\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Draft updated to version 8
require 'uri'
require 'net/http'

url = URI("https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"expectedVersionId\": 7\n}"

response = http.request(request)
puts response.read_body
```

```java Draft updated to version 8
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"expectedVersionId\": 7\n}")
  .asString();
```

```php Draft updated to version 8
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft', [
  'body' => '{
  "expectedVersionId": 7
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Draft updated to version 8
using RestSharp;

var client = new RestClient("https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"expectedVersionId\": 7\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Draft updated to version 8
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["expectedVersionId": 7] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://staging.cail.health/v1/plan-definitions/a1b2c3d4-e5f6-4789-9abc-def012345678/draft")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```