Building Apis
Build Celigo APIs -- custom HTTP endpoints that let external systems push or query data synchronously through Celigo integrations. Use when creating APIs, proxying authenticated requests, or exposing lookup/write operations as a REST interface that returns a structured response.
- Skill ID
- celigo/ai/building-apis
- Publisher
- celigo
- Repository
- ai
- Installs
- 0
- Files
- 11
- Synced
- Sep 23, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
celigo/ai/building-apisInstalls these files- SKILL.md
- references/schemas/api-request.yml
- references/schemas/api-response.yml
- references/schemas/apim.yml
- references/schemas/builder.yml
- references/schemas/request.yml
- references/schemas/response-router.yml
- references/schemas/response.yml
- references/schemas/router.yml
- references/schemas/script.yml
- references/schemas/shipworks.yml
What this skill tells the agent
<!-- TIER:1 -->
Building APIs
An API is a RESTful endpoint that exposes integration logic for external consumption. External systems call the API over HTTP; the API processes the request through lookups and imports, then returns a structured response. Concerns when building an API:
- Mode selection -- builder (visual configuration) vs script (full JavaScript control)
- Request definition -- HTTP method, URI path, parameters, body schema, request transformation
- Processing pipeline -- routers and page processors (lookups + imports) that execute business logic
- Response routing -- directing processed data to the correct response definition based on success/failure or custom conditions
- Response shaping -- status codes, field mappings, body schema, hooks (preMap, postMap) on each response
- Response mapping -- extracting fields from each page processor's response back into the record for downstream steps. Configured on each
pageProcessors[]entry, same as in flows. For lookup exports the response hasdata[]anderrors[](usedata[0].fieldNamefor single results). For imports the response is via_json(use_json.fieldName) - postResponseMap hook -- JavaScript processing after response mapping, configured on
pageProcessors[]entries
Used across integrations alongside flows and tools. APIs do not have their own authentication -- incoming requests authenticate via the Celigo API token; outbound calls to external systems use the connections referenced by exports/imports in the pipeline.
The Request IS the Source Record
APIs are invoked by an external HTTP caller -- there is no upstream export, no scheduler, no listener feeding them. That has three design consequences:
- The request stage is the input shape. Whatever the caller sends (body, path params, query params, headers) is what downstream processing sees as the record. There is no upstream pipeline to reshape it first -- use the request
transformif the envelope needs reshaping before routing. - The response stage is the output. Whatever the selected response definition produces is exactly what the caller receives. Nothing runs after it.
- No self-starting. APIs have no
schedule, no listener, and none of the flow runtime controls (proceedOnFailure,skipRetries, chaining). "Every night at 2 AM, do X" is a flow -- possibly one that calls the API, but the schedule lives on the flow. Retry-after-failure is the caller's decision.
When a flow needs to invoke an API, it does so as an ordinary HTTP caller (an HTTP export/import pointing at the API's URL). There is no special flow-step-to-API wiring.
A top-level disabled: true takes the API offline without deleting it -- callers get a 404 until it's re-enabled.
API Modes
Builder Mode (type: "builder")
Visual configuration with discrete components:
API (type: "builder")
+-- request -- method, relativeURI, params, bodySchema, mockRequest, transform
+-- routers[] -- processing pipeline (same structure as flow routers)
| +-- branches[]
| +-- inputFilter -- when to use this branch (s-expression rules)
| +-- pageProcessors[] -- lookups (exports) and imports
| +-- nextRouterId -- chain to next router, or "apiRouter" to finish
+-- responseRouter -- id="apiRouter", routes processed data to a response
+-- responses[] -- success, fail, custom -- each with statusCode, inputFilter, mappingsThe incoming HTTP request replaces the export as data source. Routers and page processors work identically to flows.
API Execution Pipeline (Builder Mode)
When an API receives a request:
- Request received -- method + path matched against the API endpoint definition
- Request transform (optional) -- reshapes the incoming request body before routing
- Router evaluation --
routeRecordsUsingevaluates branch input filter conditions - Branch selection -- first matching branch processes the request
- Page processors -- each processor in the branch executes sequentially (export lookups, import writes)
- Response mapping --
responseMappingon each processor carries data forward to the next processor - Response router --
responseRouter(id="apiRouter") selects which response template to use based on response input filters - Response -- selected response template returned to the caller with its statusCode, headers, and body
Script Mode (type: "script")
A single handleRequest JavaScript function receives the request object (method, headers, queryParams, body, pathParams) and returns {statusCode, headers, body}. Complete control with no visual configuration.
Legacy APIs (no type field, top-level _scriptId + function) exist in production but are not represented in the current spec. Distinguish by: if type is absent/null and _scriptId is present, it's legacy.
Quick Reference
Decision Matrix
| Scenario | Mode | Why |
|---|---|---|
| Standard lookup/write with structured response | Builder | Visual debugging, test runs, structured responses |
| Multiple response shapes based on success/failure | Builder | Response router + inputFilter handles this declaratively |
| Complex conditional logic or custom auth validation | Script | Full JavaScript control over request/response |
| Dynamic routing that can't be expressed as input filters | Script | handleRequest can implement arbitrary logic |
| Proxy through an authenticated connection | Builder | Wire the connection's export/import as a page processor |
| Simple webhook receiver that transforms and forwards | Builder | Single router, single branch, one import |
Minimum Required Fields
| Mode | Required Fields |
|---|---|
| Builder | name, type: "builder", builder.request (method + relativeURI) |
| Script | name, type: "script", script._scriptId, script.function |
| Legacy | name, _scriptId, function (no type field) |
Schema Index
All schemas are in references/schemas/:
| Schema | What it defines |
|---|---|
| request.yml | Top-level API fields (name, type, version, disabled, builder/script refs) |
| response.yml | API response shape |
| builder.yml | Builder configuration (request, routers, responseRouter, responses refs) |
| api-request.yml | Request config (method, relativeURI, params, bodySchema, mockRequest, transform) |
| api-response.yml | Response definitions (id, name, type, statusCode, inputFilter, mappings, hooks) |
| response-router.yml | Response router (id="apiRouter", routeRecordsUsing) |
| router.yml | Routers (branches, inputFilter, pageProcessors) |
| script.yml | Script config (_scriptId, function) |
| apim.yml | APIM metadata (publication status) |
| shipworks.yml | Legacy ShipWorks auth |
Related Skills
- configuring-exports > Quick Reference -- building lookup exports used as page processors in the API pipeline
- configuring-imports > Quick Reference -- building imports used as page processors in the API pipeline
- building-flows > How to Build a Flow -- flows share the same router/branch/pageProcessor pipeline mechanics
- writing-scripts > Quick Reference -- writing
handleRequest(script-mode APIs),preMap/postMaphooks, andpostResponseMap
More from celigo
Use this skill in a project
Open any RiverX project, search the Skills panel for celigo/ai/building-apis, and install it in one click.
