Skip to main content

Operation

An operation is an endpoint of your API. It is bound to an HTTP method and path, i.e. POST /answers/:answerId/vote, and invokes an action which contains the business logic. Besides the route, an operation describes everything a client needs to know about the endpoint: which parameters it accepts, which data it expects and returns, and who is allowed to call it.

operation_detail

What an operation defines​

You can think of an operation as a contract between your API and its clients. Every operation defines:

PartDescription
RouteThe HTTP method and path, i.e. GET /contracts/:id, and the HTTP status code of a success response
ParametersThe query parameters which the endpoint accepts, i.e. ?startIndex=0&count=16
IncomingThe schema of the request body
OutgoingThe schema of the success response
ThrowsThe schemas of the error responses, i.e. for 404 or 500
ActionThe business logic which is executed
AccessWhether the operation is public or requires an access token with specific scopes
StabilityThe lifecycle state, i.e. Experimental or Stable
CostsOptional points which a user pays for every call, if you monetize your API

Because all this information is part of the operation, Fusio can validate incoming requests, and generate an OpenAPI specification, documentation and type-safe client SDKs for your API automatically.

All settings are explained in detail at the Configuration page.

What happens when an operation is called​

When a client sends a request to your API, Fusio processes it through the following steps before your action is executed. If a step fails, Fusio directly returns an error response and your action is not invoked:

StepDescriptionError response
1. RoutingFusio finds the operation which matches the HTTP method and path404 Not Found
2. FirewallFusio checks whether the IP of the client is blocked by the firewall, i.e. because it has caused too many client errors403 Forbidden
3. AuthenticationFor private operations Fusio checks the access token and whether it contains a scope of the operation401 Unauthorized
4. Rate limitFusio checks whether the client has exceeded its rate limit429 Too Many Requests
5. ActiveFusio checks whether the operation is active410 Gone
6. CostsIf the operation has costs, Fusio checks whether the user has enough points and deducts them402 Payment Required
7. ActionFusio invokes the action and returns its response with the configured HTTP status codedepends on the action

Every request is logged, so you can inspect it later at the backend under Analytics / Log. Fusio also adds the following headers to every response:

HeaderDescription
X-Request-IdA unique id of the request, useful i.e. to find the request at the logs
X-Operation-IdThe name of the operation which was invoked
X-StabilityThe stability of the operation, i.e. experimental or stable

Not only HTTP​

Every operation is also available through other protocols, without any additional configuration. This means a client can invoke the same operation, with the same validation, authentication and business logic, through:

  • MCP - So that AI tools and agents can use your API
  • JSON-RPC - To call operations as remote procedures
  • GraphQL - To query your API through GraphQL
  • AI Agent - To use your API as a tool of an AI agent

Topics​