> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish

> Learn how to publish your workflows and make them available via API or MCP

## Overview

Publishing a workflow in Jinba Flow makes it available for execution via API calls or as an MCP (Model Context Protocol) tool. When you publish a workflow, you create a stable version that can be accessed by external systems, other workflows, or AI assistants.

## What is Publishing?

Publishing a workflow:

* **Creates a Version**: Saves the current workflow state as a published version
* **Generates API Access**: Creates an API key that allows external access to your workflow
* **Enables API Execution**: Makes the workflow callable via REST API endpoints
* **Enables MCP Integration**: Allows the workflow to be used as an MCP tool for AI assistants
* **Locks the Version**: The published version remains stable even if you make changes to the workflow

## Publishing a Workflow

### Step 1: Prepare Your Workflow

Before publishing, ensure your workflow is:

1. **Valid**: All steps are properly configured
2. **Tested**: Run the workflow to verify it works correctly
3. **Complete**: All required inputs and outputs are defined

### Step 2: Publish from the Flow Editor

1. Open your workflow in the Flow Editor
2. Review your workflow to ensure it's ready
3. Click the **Publish** button in the editor toolbar
4. If validation passes, the workflow will be published

**Note**: The publish button may show different states:

* **Publish**: Workflow is not published
* **Republish**: Workflow is published but has unpublished changes
* **Published**: Workflow is published and up to date

### Step 3: Publishing Options

When publishing, you can choose how your workflow is made available:

#### Publish as API

Publishing as API makes your workflow accessible via REST API:

* **API Endpoint**: Your workflow can be called using HTTP requests
* **API Key**: An API key is automatically generated for authentication
* **Use Cases**: Integration with external systems, webhooks, scheduled tasks

#### Publish as MCP Tool

Publishing as MCP makes your workflow available as a tool for AI assistants:

* **MCP Integration**: The workflow appears as a tool in MCP-compatible AI assistants
* **Parameter Configuration**: Define input parameters that AI assistants can use
* **Use Cases**: AI-powered automation, assistant workflows, conversational interfaces

**Note**: You can publish a workflow as both API and MCP simultaneously.

## Publishing Process

### Direct Publishing

For most workspaces, publishing is immediate:

1. Click **Publish** in the flow editor
2. The workflow is validated
3. A new version is created and marked as published
4. An API key is generated (if not already exists)
5. The workflow becomes available via API/MCP

### Approval Process (Enterprise)

For Enterprise workspaces with approval processes enabled:

1. Click **Publish** in the flow editor
2. Enter an optional comment explaining the changes
3. Submit an approval request
4. The workflow version is created but not immediately published
5. An approver reviews and approves the request
6. Once approved, the workflow is automatically published

**Approval Workflow**:

* Approval requests appear in the approver's dashboard
* Approvers can review changes and comments
* Approvers can approve or reject the request
* Approved workflows are automatically published

## Unpublishing a Workflow

You can unpublish a workflow to make it unavailable:

1. Open the published workflow in the Flow Editor
2. Click the **Publish** toggle to turn it off
3. Confirm the unpublish action
4. The workflow is no longer accessible via API or MCP

**Important Notes**:

* Unpublishing does not delete the workflow or its versions
* You can republish at any time
* If the workflow is published as MCP, unpublishing will remove it from MCP tools
* API keys remain but the workflow won't be accessible

## Published Versions

### Version Management

When you publish a workflow:

* **Version Created**: A new flow version is created with label "PUBLISH"
* **Version History**: All published versions are saved in version history
* **Stable Reference**: The published version remains unchanged even if you edit the workflow
* **Version Comparison**: You can compare different versions to see changes

### Republishing

When you make changes to a published workflow:

1. The workflow shows "unpublished changes" indicator
2. Click **Republish** to publish the new version
3. The new version replaces the previous published version
4. The old version remains in history for reference

## Using Published Workflows

### Via API

Once published, you can call your workflow via API:

```bash theme={null}
curl -X POST https://api.jinba.dev/api/v1/flows/{flow-id}/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "args": [
      {"name": "input1", "value": "example"}
    ]
  }'
```

### Via MCP

Published workflows appear as tools in MCP-compatible AI assistants:

* **Tool Name**: Based on your workflow name
* **Parameters**: Defined input parameters from your workflow
* **Description**: Uses your workflow description
* **Usage**: AI assistants can invoke your workflow as a tool

### Via JINBA\_FLOW\_RUN Tool

You can also call published workflows from other workflows using the `JINBA_FLOW_RUN` tool:

```yaml theme={null}
- id: call_published_flow
  name: call_published_flow
  tool: JINBA_FLOW_RUN
  config:
    - name: token
      value: "{{secrets.JINBA_API_TOKEN}}"
  input:
    - name: id
      value: "{{secrets.PUBLISHED_FLOW_ID}}"
    - name: args
      value:
        - name: input1
          value: "example value"
```

## API Keys

### Automatic Generation

When you publish a workflow:

* An API key is automatically generated
* The key is scoped to the specific workflow
* The key is stored securely in your workspace
* You can view the key in workflow settings

### Managing API Keys

1. Go to your workflow settings
2. Navigate to the **API** or **Publish Settings** section
3. View or regenerate your API key
4. Use the key in API requests for authentication

**Security Best Practices**:

* Never share API keys publicly
* Rotate keys regularly
* Use different keys for different environments
* Revoke keys if compromised

## Publishing Best Practices

1. **Test Before Publishing**: Always test your workflow thoroughly before publishing
2. **Version Control**: Use meaningful version labels and comments
3. **Documentation**: Document your workflow's inputs, outputs, and behavior
4. **Error Handling**: Implement proper error handling in your workflows
5. **Security**: Review permissions and access controls before publishing
6. **Monitoring**: Monitor published workflow usage and performance
7. **Gradual Rollout**: Test with a small audience before full deployment

## Publishing Status Indicators

The flow editor shows different states:

* **Unpublished**: Workflow is not published (gray indicator)
* **Published**: Workflow is published and up to date (green indicator)
* **Unpublished Changes**: Workflow has changes not yet published (yellow indicator)
* **Publishing**: Workflow is currently being published (loading indicator)

## Troubleshooting

### Cannot Publish

* **Validation Errors**: Fix any validation errors in your workflow
* **Missing Permissions**: Ensure you have publish permissions
* **Approval Required**: Submit an approval request if required

### Published Workflow Not Accessible

* **Check API Key**: Verify the API key is correct
* **Check Permissions**: Ensure the API key has proper permissions
* **Verify Endpoint**: Confirm you're using the correct API endpoint
* **Check Status**: Verify the workflow is actually published

### MCP Tool Not Appearing

* **Publish Required**: The workflow must be published to appear as MCP tool
* **MCP Configuration**: Ensure MCP is properly configured in workspace settings
* **Parameter Definition**: Define input parameters for MCP tool usage

## Related Features

* [Workspace](/en/pages/basics/workspace) - Learn about workspace management
* [MCP](/en/pages/basics/mcp) - Learn about Model Context Protocol integration
* [Archive Feature](/en/pages/basics/archive) - Learn about archiving workflows
