Contact Us 1-800-596-4880

Creating API Specs with MuleSoft Dev Agent

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

MuleSoft Dev Agent is a purpose-built assistant for the development lifecycle, available directly in Anypoint Code Builder. It provides a unified panel that lets you interact with AI features using natural language prompts. Dev Agent works with the embedded MuleSoft MCP Server (see Mulesoft MCP Server) to support capabilities such as deploying applications, managing instances, and creating new projects.

One of these capabilities is AI-powered API specification generation. With Dev Agent, you can generate and mock API specifications from natural language prompts. This feature reduces the time spent on API design by simplifying the creation of syntax-heavy specifications.

Before You Begin

Before you start creating your API spec, make sure you meet the following prerequisites:

Authentication happens through the user logged into Anypoint Code Builder. MuleSoft Dev Agent inherits the same permissions as that user and can only execute actions that the user is authorized to perform in Anypoint Platform.

Design an API Spec with AI

To design an API spec with MuleSoft Dev Agent:

  1. Open MuleSoft Dev Agent from the toolbar or from the Build Your Ecosysyem with AI card in the canvas.

  2. Enter a prompt that describes your API specification.

    Include these required details and consider including optional details to generate a more precise spec:

    Base Details

    Optionally provide the API name, version, and description.

    Security Details

    Include a required security scheme of type Oauth 1.0, Oauth 2.0, Basic Authentication, Digest Authentication, or Pass Through.

    • For Basic Authentication, Digest Authentication, or Pass Through, specify responses, query parameters, and headers.

    • For Oauth 1.0 or 2.0, specify responses, query parameters, headers, and settings.

      • Settings for Oauth 1.0 can be of type authorizationUri, requestTokenUri, tokenCredentialsUri, or signatures.

      • Settings for Oauth 2.0 can be of type authorizationUri, requestTokenUri, or authorizationGrants.

    The following additional details apply:

    Header Requirements

    Headers must include the name, whether it’s required, and one of the following types:

    • Array

    • Boolean

    • Date only

    • DateTime

    • DateTime only

    • File

    • nil

    • Number

    • Object

    • String

    • Time only

    Optionally, provide a description, format, minimum and maximum length, default value, and example for the header.

    Query Parameter Requirements

    Query parameters must include the name, whether it’s required, and one of the following types:

    • Array

    • Boolean

    • Date only

    • DateTime

    • DateTime only

    • File

    • nil

    • Number

    • Object

    • String

    • Time only

    Optionally, provide a description, format, minimum and maximum length, default value, and example for the query parameter.

    Response Requirements

    Responses must include the status code and description.

    Resources and Methods

    Include a required security scheme of type Oauth 1.0, Oauth 2.0, Basic Authentication, Digest Authentication, or Pass Through.

    The following additional details apply:

    Resource Requirements

    Each resource can include one or more of the following methods:

    • GET

    • POST

    • PUT

    • PATCH

    • DELETE

    • HEAD

    • OPTIONS

    For GET and HEAD methods, you can include a summary, responses, requests, and query or header parameters.

    For POST, PUT, PATCH, and OPTIONS methods, you can include a summary, responses, requests, body, and query or header parameters.

    Response Requirements

    Responses must include the status code and description. Response bodies are optional and can include a description, type, media type, and example.

    Request Requirements

    Requests must include a description and body.

    Header Requirements

    Headers must include the name, whether it’s required, and one of the following types:

    • Array

    • Boolean

    • Date only

    • DateTime

    • DateTime only

    • File

    • nil

    • Number

    • Object

    • String

    • Time only

    Optionally, provide a description, format, minimum and maximum length, default value, and example for the header.

    Query Parameter Requirements

    Query parameters must include the name, whether it’s required, and one of the following types:

    • Array

    • Boolean

    • Date only

    • DateTime

    • DateTime only

    • File

    • nil

    • Number

    • Object

    • String

    • Time only

    Optionally, provide a description, format, minimum and maximum length, default value, and example for the query parameter.

  3. Send your message. The agent creates a validated API spec.

Governance isn’t included in the validation.
  1. Enter your prompt in MuleSoft Dev Agent and submit it.

  2. Review the generated specification.

  3. If Auto-approve is enabled, Dev Agent writes the generated API spec directly into your project files.

  4. If Auto-approve is disabled, Dev Agent prompts you to approve or reject each file change before applying it.

  5. After the API project is generated, you can also:

    • Ask Dev Agent to publish the API asset to Exchange.

    • Add governance rulesets to validate your specification.

    • Mock requests to the API directly from the IDE.

Define Rules and Workflows

To define reusable rules and workflows for MuleSoft Dev Agent:

  1. In the MuleSoft Dev Agent panel, click the Rules/Workflows icon in the lower-left corner (next to the Context icon).

  2. Choose one of the following tabs:

    • Rules: Define constraints or guidelines for how the API spec should be generated.
      For example, enforce naming conventions or require consistent error handling.
      Rules can be defined at the Global Rules or Workspace Rules level.

    • Workflows: Create a series of steps that MuleSoft Dev Agent executes as a predefined action.
      Workflows are invoked using slash commands (for example, /workflow-name) in the MuleSoft Dev Agent panel.

Provide Additional Context

You can provide additional inputs, such as requirement files (for example, requirements.txt), terminal outputs, or project folders, to help Mulesoft Dev Agent generate more accurate API specifications. These files are used as contextual references during API generation.

To add context:

  1. In the MuleSoft Dev Agent panel, click the Add Context icon in the lower-left corner.

  2. Select the file or folder you want to attach, or paste terminal input/output.

  3. Confirm to add the context to your current task.

MuleSoft Dev Agent Settings

You can control how MuleSoft Dev Agent interacts with your project through the Settings panel. To access this panel, click the Auto-approve section at the bottom of the MuleSoft Dev Agent window.

Available settings are:

  • Auto-approve: Enable to apply changes automatically without prompting for confirmation.
    If Auto-approve is disabled, Dev Agent will request your approval before making any file changes.

  • Read project files: Allow MuleSoft Dev Agent to read project files for context.

  • Edit project files: Allow MuleSoft Dev Agent to write changes directly to your project.

  • Read all files: Allow MuleSoft Dev Agent to read all files on your computer.

  • Edit all files: Allow MuleSoft Dev Agent to edit any file on your computer.

  • Use MCP Servers: Allow MuleSoft Dev Agent to use connected MCP servers.

  • Execute safe commands: Allow MuleSoft Dev Agent to execute safe terminal commands.

  • Execute all commands: Allow MuleSoft Dev Agent to execute any terminal command.

  • Use the browser: Allow MuleSoft Dev Agent to launch and interact with websites in a browser.