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

# Ensure full product (config-as-code converge of the whole FPO)

POST https://api.runtype.com/v1/products/ensure-fpo
Content-Type: application/json

Idempotently converge an entire Full Product Object (the nested product graph) in one shot. Fans out to the per-entity ensure services in dependency order (product → capability backing flows/agents → capability-as-tool composition → capability links → surfaces + surface items → records → schedules → secret bindings), returning a per-entity report. Identity is the product name + account scope. NON-atomic by design: a per-entity failure is reported in `entities[].result = "failed"` (and `hasFailures`) and a re-run self-heals; only a top-level product reject aborts. Converged capability agents and flows are published to `live` by default; set release to "none" to save changes as drafts. Set dryRun to plan without writing. Set prune to remove product-scoped capabilities/surfaces (and their items) absent from the FPO (account-scoped flows/agents/tools/records are never removed). A hash-only probe (`name` + `contentHash`, no fpo) with release "none" answers `unchanged` when the live graph reconstructs (as GET /products/pull-fpo does) to that hash, else `definitionRequired` (retry with the full fpo); a probe that publishes (the default release) always answers `definitionRequired`, because only a full converge can publish drafts that are not yet live. The probe, the dryRun `remoteHash` and expectedRemoteHash read the live graph, so API keys need PRODUCTS:READ for them. A dryRun reports the live graph's `remoteHash`; pass it as expectedRemoteHash on the apply to refuse the write (409 remote_changed) if the product changed in between. The guard compares what GET /products/pull-fpo reconstructs, so edits to seed records, schedules or secrets (which pull-fpo omits) do not trip it. When pull-fpo has to omit part of the product (a capability, surface, schedule, eval suite or skill it cannot represent), a probe answers `definitionRequired`, a dryRun reports no `remoteHash`, and expectedRemoteHash is refused with 409. The guard is re-checked immediately before the first write but does not lock the graph, so an edit that lands while the apply is running can still be overwritten. API keys need PRODUCTS:CREATE to create the product and PRODUCTS:UPDATE to change an existing one (PRODUCTS:WRITE covers both). API keys converge each nested flow, agent, tool, surface, schedule, record, eval suite and skill only with that entity kind's own write scope (FLOWS:WRITE, AGENTS:WRITE or AGENTS:CREATE/UPDATE, TOOLS:WRITE, PRODUCTS:SURFACES:WRITE, SCHEDULES:WRITE, RECORDS:WRITE, EVALS:WRITE, SKILLS:WRITE) on top of the product scope; otherwise that entity reports `failed`. Adding or changing a capability on an existing product needs PRODUCTS:CAPABILITIES:WRITE, and adding a route to an existing surface needs PRODUCTS:SURFACES:WRITE. Prune needs PRODUCTS:CAPABILITIES:WRITE to remove capabilities and PRODUCTS:SURFACES:WRITE to remove surfaces or their items, and a pruned surface's client tokens are revoked. Binding a skill to an agent also needs agent update scope. Schedules also honor the plan's active-schedule limit and minimum frequency.

Reference: https://docs.runtype.com/api-reference/runtype-api/products/ensure-full-product-config-as-code-converge-of-the-whole-fpo

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Body (application/json)

This endpoint expects an object.

- `contentHash` (string, optional) — Hash-only probe: the canonical FPO hash the caller holds. Answers `unchanged` when the live graph reconstructs (as pull-fpo does) to this hash, else `definitionRequired`. Only valid without `fpo`.
- `dryRun` (boolean, optional) — Plan without writing — returns a per-entity plan (CI drift gate).
- `expectedRemoteHash` (string, optional) — TOCTOU guard binding a dry run to its apply: the write proceeds only while the live graph still hashes to this value (the dry run's `remoteHash`); otherwise 409 remote_changed.
- `fpo` (map from string to any, optional) — A complete Full Product Object (FPO): the nested product graph (product, capabilities, tools, surfaces, ...). Validated server-side via the shared FPO validator. Omit it only for a hash-only probe (`name` + `contentHash`).
- `name` (string, optional) — The product name a hash-only probe resolves. Only valid without `fpo`.
- `onConflict` (enum, optional) — Per nested entity: "overwrite" converges over dashboard/API edits.
  - Allowed values: `error`, `overwrite`
- `prune` (boolean, optional) — Opt-in removal of product-scoped capabilities/surfaces (and their items) absent from the FPO, after the converge passes. NEVER touches account-scoped flows/agents/tools/records. Honors createPolicy:"skip". With dryRun, reports would-be removals as `pruned` plan rows.
- `release` (enum, optional) — Whether converged capability agents and flows go live. Defaults to "publish": an agent or flow whose converged content is not yet live is versioned and published (the agent's `live` alias moves to that version), matching product creation. "none" saves changes as drafts and leaves `live` where it was. Publishing needs update authority over that entity kind, and for an agent the live deploy scope (AGENTS:DEPLOY:LIVE; AGENTS:WRITE or AGENTS:UPDATE also accepted); an API key without it converges that kind as "none".
  - Allowed values: `none`, `publish`

## Response

### 200

Converge result: unchanged | converged | plan (dryRun), with a per-entity report; or definitionRequired (hash-only probe miss — retry with the full fpo).

- `ProductFpoEnsureResponse`
  - ProductFpoEnsureResponse0
  - ProductFpoEnsureResponse1

## Errors

### 400 Bad Request Error

FPO validation error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 403 Forbidden Error

Insufficient permissions

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 409 Conflict Error

Conflict: external_modification converging the top-level product, or remote_changed (expectedRemoteHash guard).

- `code` (enum, required)
  - Allowed values: `external_modification`, `remote_changed`
- `error` (string, required)
- `currentHash` (string, optional, nullable)
- `lastModifiedSource` (string, optional)
- `modifiedAt` (string, optional, nullable)

### 422 Unprocessable Entity Error

Submitted contentHash does not match the server-recomputed canonical hash

- `code` (enum, required)
  - Allowed values: `content_hash_mismatch`
- `contentHash` (string, required) — The server-computed canonical hash of the submitted definition.
- `error` (string, required)

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### ProductFpoEnsureResponse0

- `contentHash` (string, required) — Server-computed canonical whole-FPO content hash.
- `entities` (list of ProductFpoEnsureResponseOneOf0EntitiesItems, required)
- `hasFailures` (boolean, required) — True when one or more entities failed to converge (re-run to self-heal).
- `result` (enum, required) — `unchanged` when every entity was unchanged (a matching hash-only probe reports no entities), `converged` when at least one was created/updated, `plan` for dryRun.
  - Allowed values: `unchanged`, `converged`, `plan`
- `productId` (string, optional)
- `remoteHash` (string, optional) — dryRun only: the live graph's pull-fpo hash, absent when the product does not exist or the caller cannot read every section. Pass it back as expectedRemoteHash to guard the apply.

### ProductFpoEnsureResponse1

- `result` (enum, required)
  - Allowed values: `definitionRequired`

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### ProductFpoEnsureResponseOneOf0EntitiesItems

- `kind` (enum, required)
  - Allowed values: `product`, `flow`, `agent`, `capability`, `tool`, `surface`, `record`, `schedule`, `eval`, `skill`, `collection`, `questionSet`
- `name` (string, required)
- `ref` (string, required) — The FPO-local ref (capability id / entity name) for correlation.
- `result` (enum, required)
  - Allowed values: `created`, `updated`, `unchanged`, `failed`, `skipped`, `pruned`
- `error` (string, optional)
- `id` (string, optional) — Resulting platform id (absent on failure/skip/pruned).
- `warnings` (list of string, optional) — Non-blocking advisories, e.g. SCHEDULE_AGENT_CONFIG_UNSUPPORTED when converging an agent moved `live` onto a version its active schedules cannot run.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "contentHash": "string",
  "entities": [
    {
      "error": "string",
      "id": "string",
      "kind": "product",
      "name": "string",
      "ref": "string",
      "result": "created",
      "warnings": [
        "string"
      ]
    }
  ],
  "hasFailures": true,
  "productId": "string",
  "remoteHash": "string",
  "result": "unchanged"
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/products/ensure-fpo"

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

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

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/products/ensure-fpo';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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://api.runtype.com/v1/products/ensure-fpo"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", 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://api.runtype.com/v1/products/ensure-fpo")

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

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

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.post("https://api.runtype.com/v1/products/ensure-fpo")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/products/ensure-fpo', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/products/ensure-fpo");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/products/ensure-fpo")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```