DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Level Up Your API Design: 8 Principles for World-Class REST APIs
  • API Design First: AsyncAPI in .Net
  • Rate Limiting Strategies for Efficient Traffic Management

Trending

  • Scaling Cloud Data Automation: A Practical Guide to Open Table Formats
  • From Data Movement to Local Intelligence: The Shift from Centralized to Federated AI
  • Chaos Engineering Has a Blind Spot. Agentic AI Lives in It.
  • No More Cheap Claude: 4 First Principles of Token Economics in 2026
  1. DZone
  2. Data Engineering
  3. Databases
  4. Mule4 Proxy API

Mule4 Proxy API

Proxy API to hide the complexity of backed API from client

By 
Ankur Bhuyan user avatar
Ankur Bhuyan
·
Nov. 18, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
18.8K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

If we want to hide our back-end API's complexity from the client or don't want our client to update their API configurations frequently due to our API endpoint changes, this blog will give you an idea about design proxy API.

Requirements

  • Multiple APIs are deployed in different hosts and those are consuming by a client, and we want a single endpoint to handle those multiple calls for different APIs.

Proxy API Design

mulesoft proxy api

As per this design, client is not going to configure multiple backend API configurations in their side. They need to configure a single endpoint (i.e the proxy api endpoint). They need to pass all the backend API required informations in BODY section of proxy API while calling. On behalf of client, proxy API will call the required API and respond to client. The response could be valid or invalid, proxy API will pass the same to client.

1st Layer of Validation: CI/CS

As per basic Mulesoft standard, proxy API will enabled to default Client Id enforcement policy.

2nd Layer of Validation: Schema Validation

 The second layer of validation would be payload validation. The RAML schema validation will make sure about the mandatory payload validation. For example, 

  1. whitelisted host (defined as mandatory enum).
  2. Method (Rest HTTP methods are defined as mandatory enum) of backend endpoint.
  3. Endpoint (backend endpoint details).
  4. Forwarder-content-type (The content-type expecting by the backend API). Which is not a mandatory for schema validation, as some backend endpoints may not required that.
  5. Body (The actual payload required by the backend API). Which is also optional. It would depend on the backend endpoint. We define the body type as "any" in RAML schema validation as the body type could be anything (like json, string, urlEncoded, etc.)

Sample RAML Schema (in Proxy API)request-mapping

WhiteList the Backend API Hosts

In this design, proxy api will not save any client or back-end API details apart from host and port. That will create one layer of security. It means Proxy API will WHITELIST those backend API (by storing only the host and port in properties file), So that those stored host can only reachable via proxy api, nothing else.

Headers

The Security headers like Basic Authentication, Bearer Token, JWT, SSO, Client Id, Client Secret all can be pass through this proxy API. We have to send them in the header section and proxy API will pass them to the backend. Because, as those are sensitive data and any design standard does not encourage headers values to be replaced with body/payload.

Sample Request Message

HTTP
 




x
38


 
1
POST /api/callBackend HTTP/1.1
2
Host: localhost:8082
3
Authorization: Basic YW5rdXI6Ymh1eWFu
4
client_id: test
5
client_secret: test
6
Content-Type: application/json
7
Content-Length: 845
8

          
9
{
10
    "host": "backend01",
11
    "method": "POST",
12
    "endpoint": "/api/createEmployee",
13
    "forwarder-content-type": "application/json",
14
    "body": {
15
        "firstName": "Ankur",
16
        "middleName": "Jyoti",
17
        "lastName": "Bhuyan",
18
        "email": "[email protected]",
19
        "gender": "Male",
20
        "phone": 9590951212,
21
        "currentAddress": {
22
            "isCurrentAddress": true,
23
            "street": "Elcetronic City",
24
            "city": "Bangalore",
25
            "district": "Bangalore",
26
            "pin": 56860,
27
            "country": "India"
28
        },
29
        "permanentAddress": {
30
            "isCurrentAddress": false,
31
            "street": "3 Rue Renee Aspe",
32
            "city": "Toulouse",
33
            "district": "Occitanie",
34
            "pin": 31000,
35
            "country": "France"
36
        }
37
    }
38
}



Proof Of Concept

To proof this proxy API design I prepared a POC. I developed this poc by configuring them using Mule4 domain project. Here is an overview.

backend API

Kindly find all the poc code here. And also find the postman script to test the endpoints,  kindly find here.

Author's Comments

  • This design will best for those who has frequent changes in backend APIs.
  • This design will best for those who has complex configuration in backend APIs.
  • If we want to reduce the number of deployment cycles of our client API for new changes in back-end API(deployed in the same host/server), this design would be helpful.
  •  This proxy api design will help to reduce the development and deployment hours and also developer's efforts.
  • This design is proven only when we have body type of application/json, application/xml, text/plain, application/x-www-form-urlencoded. Not for multipart/form-data (file upload). But, I hope that also could be possible with this design.
API Design Host (Unix)

Opinions expressed by DZone contributors are their own.

Related

  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Level Up Your API Design: 8 Principles for World-Class REST APIs
  • API Design First: AsyncAPI in .Net
  • Rate Limiting Strategies for Efficient Traffic Management

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook