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

# Save Harbor Context Draft

PUT https://app.polytomic.com/api/harbors/{harbor_id}/contexts/{context_id}/draft
Content-Type: application/json

Creates or completely replaces the mutable draft for a Harbor context document.

The request supplies the complete draft payload. If a draft already exists,
this request replaces it while preserving the draft ID, creation metadata, and
`base_revision_id`.

A new draft for a published document records the current revision as its base.
An unpublished document's initial draft keeps a null base when replaced. Saving
a draft does not change published content or its `updated_at`. Creator and
updater provenance comes from the request actor; system actors have a null actor
ID.

Reference: https://apidocs.polytomic.com/api-reference/harbors/save-context-draft

## Authentication

- `Authorization` header (bearer token, required) — Bearer user API key
- `Authorization` header (basic auth, required) — Basic organization-scoped API key

## Request

### Path parameters

- `harbor_id` (string, required) — Unique identifier of the Harbor.
- `context_id` (string, required) — Unique identifier of the context document.

### Headers

- `X-Polytomic-Harbor-Session` (string, optional)
- `X-Polytomic-Activity-Request-ID` (string, optional)

### Body (application/json)

This endpoint expects a SaveHarborContextDraftRequest.

- `content` (string, required) — Complete plain-text draft content. Maximum 20,000 characters.
- `title` (string, required) — Human-readable draft title. Maximum 200 characters.
- `change_note` (string, optional, nullable) — Optional note stored with the draft and copied to the published version on promotion.
- `description` (string, optional) — Short summary of the draft. Maximum 1,000 characters.

## Response

### 200

OK

- `data` (HarborContextDraftResponse, optional)

## Errors

### 403 Forbidden Error

Forbidden

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 404 Not Found Error

Not Found

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 422 Unprocessable Entity Error

Unprocessable Entity

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 500 Internal Server Error

Internal Server Error

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

## Types

### HarborContextDraftResponse

- `base_revision_id` (string, optional, nullable) — Published revision on which this draft is based. Null for an unpublished context's initial draft.
- `change_note` (string, optional, nullable) — Optional note copied to the published version on promotion.
- `content` (string, optional) — Complete plain-text draft content.
- `context_id` (string, optional) — Stable context document identity. Use this ID for draft replacement, promotion, and discard.
- `created_at` (datetime, optional) — When the draft was created.
- `created_by` (string, optional, nullable) — Actor that created the draft. Null for the system actor.
- `created_by_type` (string, optional) — Type of actor that created the draft.
- `description` (string, optional) — Draft description.
- `id` (string, optional) — Unique identifier of the mutable draft.
- `title` (string, optional) — Draft title.
- `updated_at` (datetime, optional) — When the draft was most recently replaced.
- `updated_by` (string, optional, nullable) — Actor that most recently replaced the draft. Null for the system actor.
- `updated_by_type` (string, optional) — Type of actor that most recently replaced the draft.

## Examples

**Request**

```json
{
  "content": "Bookings use the contract signed date...",
  "title": "Revenue definitions"
}
```

**Response**

```json
{
  "data": {
    "base_revision_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "change_note": "string",
    "content": "string",
    "context_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "created_at": "2024-01-15T09:30:00Z",
    "created_by": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "created_by_type": "string",
    "description": "string",
    "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "title": "string",
    "updated_at": "2024-01-15T09:30:00Z",
    "updated_by": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "updated_by_type": "string"
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft"

payload = {
    "content": "Bookings use the contract signed date...",
    "title": "Revenue definitions"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"content":"Bookings use the contract signed date...","title":"Revenue definitions"}'
};

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

```go
package main

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

func main() {

	url := "https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft"

	payload := strings.NewReader("{\n  \"content\": \"Bookings use the contract signed date...\",\n  \"title\": \"Revenue definitions\"\n}")

	req, _ := http.NewRequest("PUT", 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
require 'uri'
require 'net/http'

url = URI("https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"content\": \"Bookings use the contract signed date...\",\n  \"title\": \"Revenue definitions\"\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"content\": \"Bookings use the contract signed date...\",\n  \"title\": \"Revenue definitions\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft', [
  'body' => '{
  "content": "Bookings use the contract signed date...",
  "title": "Revenue definitions"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"content\": \"Bookings use the contract signed date...\",\n  \"title\": \"Revenue definitions\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "content": "Bookings use the contract signed date...",
  "title": "Revenue definitions"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/harbors/248df4b7-aa70-47b8-a036-33ac447e668d/contexts/248df4b7-aa70-47b8-a036-33ac447e668d/draft")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```