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

# Automate with API

> Gate deployments on simulation test results using the Agents API.

Test runs are most useful when they gate deployments. The [Agents API](/api-reference/build-deploy/agents-api/overview) gives you publish and promote actions you can chain behind a passing test set.

## Gate promotions on test results

A typical CI job [publishes](/api-reference/api-reference/agents/deployments/publish) the current draft to Sandbox, runs the relevant test set, and only [promotes](/api-reference/api-reference/agents/deployments/promote) to Pre-release if the set passes.

```mermaid
flowchart LR
    A[Publish Draft → Sandbox] --> B[Run test set]
    B -->|Pass| C[Promote → Pre-release]
    B -->|Fail| D[Block promotion]
```

Use the [Deployments endpoints](/api-reference/api-reference/agents/deployments/publish) to wire this into your CI pipeline.

## Related pages

#### [Simulation tests](/agent-studio/testing/simulation-tests)

Author the test cases that CI runs.

#### [Run and review](/agent-studio/testing/run-and-review)

Organize tests into sets for CI.

#### [Environments](/agent-studio/deployments/overview)

How versions move through Sandbox, Pre-release, and Live.

#### [Deployments API](/api-reference/api-reference/agents/deployments/publish)

Publish, promote, and rollback endpoints.