You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`context.route`|`string`| The route suffix, including the leading slash, e.g. `""`, `"/verify"`, `"/settle"`. |
126
+
|`context.method`|`"GET" \| "POST"`| The HTTP method used to invoke the plugin. |
127
+
|`context.query`|`Record<string, string[]>`| Query parameters parsed from the request URL. Most useful for `GET` invocations. |
128
+
|`context.config`|`unknown`| User-defined plugin configuration object from `plugins[].config` in the Relayer config file. |
129
+
130
+
<Callout>
131
+
`context.params` is user-provided input. Prefer defining a `type` for your params, validating required fields, and using
132
+
`pluginError(...)` to return structured 4xx errors.
133
+
</Callout>
134
+
101
135
#### Legacy Patterns (Deprecated, but supported)
102
136
103
137
<Callouttype="warn">
@@ -140,14 +174,18 @@ The file contains a list of plugins, each with an id, path, timeout in seconds (
140
174
Example:
141
175
142
176
```json
143
-
144
177
"plugins": [
145
178
{
146
179
"id": "my-plugin",
147
180
"path": "my-plugin.ts",
148
181
"timeout": 30,
149
182
"emit_logs": false,
150
183
"emit_traces": false,
184
+
"raw_response": false,
185
+
"allow_get_invocation": false,
186
+
"config": {
187
+
"featureFlagExample": true
188
+
}
151
189
"forward_logs": false
152
190
}
153
191
]
@@ -231,9 +269,28 @@ console.log(result);
231
269
232
270
## Invocation
233
271
234
-
Plugins are invoked by hitting the `api/v1/plugins/plugin-id/call` endpoint.
272
+
Plugins are invoked by hitting the `/api/v1/plugins/{plugin-id}/call{route}` endpoint.
235
273
236
-
The endpoint accepts a `POST` request. Example post request body:
274
+
-`route` is optional. Use `/call` for a single endpoint, or `/call/<route>` to expose multiple routes from the same plugin.
275
+
- The plugin receives the route as `context.route`.
276
+
- You can implement your own routing by branching on `context.route` (for example, `"/verify"`, `"/settle"`, `""`).
277
+
278
+
Example (route-based invocation):
279
+
280
+
```bash
281
+
# Calls the plugin with context.route = "/verify"
282
+
curl -X POST http://localhost:8080/api/v1/plugins/my-plugin/call/verify \
283
+
-H "Content-Type: application/json" \
284
+
-H "Authorization: Bearer YOUR_API_KEY" \
285
+
-d '{"params":{}}'
286
+
```
287
+
288
+
The endpoint accepts a `POST` request.
289
+
290
+
- If the request body contains a top-level `params` field, that value is used as `context.params`.
291
+
- If the request body does not contain `params`, the entire JSON body is treated as `params`.
292
+
293
+
Example `POST` request body:
237
294
238
295
```json
239
296
{
@@ -247,9 +304,18 @@ The endpoint accepts a `POST` request. Example post request body:
247
304
248
305
The parameters are passed directly to your plugin’s `handler` function.
249
306
307
+
### GET invocation (optional)
308
+
309
+
By default, plugins can only be called with `POST`. To allow `GET` requests, set `allow_get_invocation: true` in the plugin configuration.
310
+
311
+
-`GET` requests invoke the plugin with an empty params object (`context.params = {}`).
312
+
- Query parameters are available to plugins via `context.query` as `Record<string, string[]>`.
313
+
250
314
## Responses
251
315
252
-
API responses use the `ApiResponse` envelope: `success, data, error, metadata`.
316
+
By default, API responses use the `ApiResponse` envelope: `success, data, error, metadata`.
317
+
318
+
If `raw_response: true` is set for a plugin, the Relayer bypasses the envelope and returns the plugin result (or plugin error) directly.
253
319
254
320
### Success responses (HTTP 200)
255
321
@@ -266,6 +332,12 @@ API responses use the `ApiResponse` envelope: `success, data, error, metadata`.
266
332
-`metadata` follows the same visibility rules (`emit_logs` / `emit_traces`).
267
333
- Plugin error logs are also forwarded to the Relayer's tracing system if `forward_logs` is enabled.
268
334
335
+
### Raw responses (`raw_response: true`)
336
+
337
+
-**Success**: the response body is the value returned by your plugin handler.
338
+
-**Error**: the response body is the plugin error payload (typically `{ "code": string | null, "details": any | null }`) and the HTTP status is taken from the error.
339
+
-**No metadata envelope**: when `raw_response` is enabled, the response does not include `metadata` even if `emit_logs` / `emit_traces` are enabled.
0 commit comments