Loading

What to Consider When Designing MuleSoft APIs with AI

Publiceringsdatum: Nov 3, 2026
Lösning

This article has been curated by the MuleSoft Success Guides team at Salesforce. If you’re interested in speaking to a Success Guide on this topic, consider opening an API Development Expert Coaching Session.


MuleSoft follows a composability approach. Every piece of functionality is broken into a building block called an API, and each block can fit into any puzzle. Teams assemble new products, channels, and processes by reusing existing blocks instead of building each integration from scratch. This article explains how to design those building blocks so they stay reusable and easy to maintain.

MuleSoft API-Led Connectivity

MuleSoft customers generally work with three types of APIs, called layers: system, process, and experience APIs. Together they form API-led connectivity. Each layer has one responsibility and can change independently of the others.

Layer

Purpose

Example

Experience APIShapes data for one channel or consumerAn API for a mobile app or partner portal
Process APICombines data and business logic from several system APIsAn order fulfillment API that combines inventory, billing, and shipping
System APIExposes a system of record and hides its complexityCustomer data from an ERP or CRM system

API-led connectivity is a guideline, not a strict rule. Not every enterprise needs all three layers, and a smaller or simpler landscape can combine or skip a layer. Most enterprises do end up using all three, because separating system access, business orchestration, and channel-specific delivery makes each API easier to reuse and change. Use the layers that fit your landscape, and add the others as it grows.

 

Design every API layer before you build

Every MuleSoft API layer requires a design. Start by writing the API specification in the latest supported version of RAML (RESTful API Modeling Language) or OAS (OpenAPI Specification), and share it with consumers for feedback before you build the implementation. You can write the specification in two ways.

Option 1: Anypoint Platform UI

Use Design Center in Anypoint Platform to write the specification in the browser. This option works well for quick edits and for teams that already manage their specifications there.

Experience API: Key design points

    • Shape the payload, size, and format for one channel or consumer, such as a mobile app or partner portal.
    • Call process APIs instead of system APIs directly, and keep the experience API thin with no business logic.
    • Handle channel concerns such as authentication, rate limits, and versioning with policies in API Manager.

Process API: Key design points

    • Orchestrate several system APIs and own the business rules, with one clear capability per process API.
    • Stay channel-neutral. Leave consumer-specific formatting to the experience layer.
    • Plan for partial failure when one system API call fails, for example with idempotent operations and a clear rollback or retry approach.

System API: Key design points

    • Expose data in a consumer-friendly model instead of the raw backend schema, so the backend's complexity stays hidden.
    • Keep business logic out. The system API handles connectivity, authentication, and basic mapping only.
    • Design for the backend's limits, such as pagination, throttling, caching, and timeouts, so a slow system does not affect consumers.

 

Option 2: Anypoint Code Builder with MuleSoft Vibes (Recommended)

Use Anypoint Code Builder (ACB), the MuleSoft development environment, with MuleSoft Vibes, the AI-assisted development capability. Describe the API in plain language, and Vibes drafts the RAML or OAS specification for you. Review and refine the draft, then build and test the implementation in the same tool. This approach speeds up design, keeps the specification and the code together, and makes it easier to apply the same naming and error response conventions across every layer.

Step 1: Sign in to ACB

Before you start, confirm that your Anypoint Platform administrator has enabled Einstein in Access Management and has given you the Mule Developer Generative AI User and ACB Developer permissions. Then open ACB, sign in with your Anypoint Platform account, and open MuleSoft Vibes from the toolbar.

Step 2: Write an effective Vibes prompt

The most effective prompt describes the whole specification in one message, so Vibes can generate and validate it in one pass. Include the following details:

    • The API name, version, and a short description of its purpose.
    • The security scheme, such as OAuth 2.0, Basic Auth, or Pass Through. Vibes requires one.
    • The resources and the methods for each (GET, POST, PUT, PATCH, DELETE), with a one-line summary of each.
    • The query parameters and headers, each with a name, a type, and whether it is required.
    • The responses for each method, with a status code, a description, and an example body. Include the error responses.

Here is an example prompt for an experience API:

"Create an OpenAPI 3.0 specification for a "Customer Orders Experience API", version 1.0.0, that lets a mobile app view a customer's orders. Use OAuth 2.0 for security. Add a GET /customers/{customerId}/orders resource with an optional query parameter "status" (string) and a required header "X-Correlation-ID" (string). Return 200 with a list of orders (order ID, status, total, and order date) and an example. Also return 400, 401, 404, and 500 with the same error body: status code, error code, message, and correlation ID."

 

 

To improve the result:

  • Attach a requirements file or an existing specification as context, so Vibes follows your data model.
  • Define Rules for naming conventions and a standard error response, so every API you generate follows the same pattern.
  • Review the generated specification before you approve it, or turn off Auto-approve so Vibes asks first.
  • Ask Vibes to mock the API or publish it to Anypoint Exchange once the specification looks right.

 

Error handling in API design

Plan for errors when you design the API, not after you build it. Define the error responses in the API specification with a consistent structure: status and error code, message, and correlation ID. 
In the Mule application, a global default error handler gives every flow the same error behavior. On Error Continue handles the error and returns a normal response. On Error Propagate handles the error and passes it to the caller or parent flow. For retries, dead-letter queues, and detailed patterns, see the Mule error handling documentation.

Designing Reusable Assets and Publishing Them in Anypoint Exchange

Anypoint Exchange is the MuleSoft catalog for sharing APIs and other assets. Well-published assets are found and reused, while poorly published assets are duplicated.

 

Recommended practices for Anypoint Exchange assets:

  • Publish API specifications, API fragments (shared data types, traits, and security schemes), connectors, templates, and examples to Exchange.
  • Give each asset a clear name, a description, and examples, and document authentication and error responses.
  • Use semantic versioning (major.minor.patch), mark old versions as deprecated, and add categories and tags so teams can find assets.
  • Share assets with the business groups that need them, name an owner for each asset, and review regularly to retire unused ones.
Ytterligare resurser

Learn More

If you want to learn more about what you can do with MuleSoft, request an Expert Coaching Session (ECS). An ECS is a one-on-one session with a MuleSoft subject matter expert who can help you apply these best practices to your own integrations: Request an Expert Coaching Individual Session.


Additional Resources

Knowledge-artikelnummer

005465274

 
Laddar
Salesforce Help | Article