--- id: API-9 family: GR-API level: core profiles: [storage-api, runtime, editor-client] posture: normative-target added: "1.1" changed: "1.1" source: https://flowdrop.io/spec/rules/gr-api/api-9 specification: FlowDrop Workflow Specification 1.0 licence: CC BY 4.0 --- # API-9 — A discovery document says where each route is *GR-API (Part I) · level: core · profiles: storage-api, runtime, editor-client · added in 1.1* The specification names routes, never paths. A client finds the path of every route a rule defines in one document the implementation publishes, so a client that drives several implementations copies none of their URL spaces. ## The rule > **Normative.** This is the rule. > > 1. An implementation MUST publish a discovery document. > > 2. The document MUST be a JSON object, served with the media type `application/json` as the whole body of the answer to a `GET` request. > > 3. It departs from the `{success, data}` envelope other answers carry because it is not the result of an operation: a client reads it before it knows any route, as it reads other well-known metadata documents, and it has no refusal of its own to tell apart from a result. > > 4. The document MUST be served to a request that carries no credentials. > > 5. An implementation MUST serve it at the path `/.well-known/flowdrop` on its origin, unless it cannot serve that path, as when it is mounted under a sub-path or is one of several on one origin. > > 6. Such an implementation MUST instead give its clients the document's URL directly. > > 7. A client MUST accept a configured discovery URL. > > 8. A client with no configured URL MUST request the default path. > > 9. The document MUST carry `endpoints`, an object mapping route names to URI templates. > > 10. Each template MUST be a path-absolute URI template of level 1, and MUST NOT carry a query component. > > 11. A client MUST resolve an expanded template against the discovery document's URL, which is the URL the client requested. > > 12. A client MUST NOT follow a redirect of the discovery request to another origin. > > 13. An identifier an implementation issues for a route variable MUST NOT be `.` or `..`. > > 14. A client MUST refuse to expand a template with either value, because level-1 expansion leaves both unencoded and resolution removes them as dot-segments, so the request would reach another path. > > 15. A route the implementation does not serve MUST have no key in `endpoints`. > > 16. A route name fixes the route's HTTP method and its template variables. > > 17. A template MUST use every variable its route name lists, and no other. > > 18. The route names, each with its method, its variables and the rules that define the route, are these. > > 19. Workflows: `workflows` (`GET`, no variables; STORE-15, API-5, API-6), `workflow_create` (`POST`, no variables; STORE-2, STORE-3, STORE-4, STORE-5), `workflow` (`GET`, `workflow_id`; STORE-14), `workflow_update` (`PUT`, `workflow_id`; STORE-2, STORE-4, STORE-5), `workflow_import` (`POST`, no variables; STORE-9), `workflow_schema` (`GET`, `workflow_id`; MAN-5, META-4, META-5, META-7) and `categories` (`GET`, no variables; META-1). > > 20. Sessions: `workflow_sessions` (`GET`, `workflow_id`; PLAY-1, PLAY-5), `session_create` (`POST`, `workflow_id`; PLAY-2), `session` (`GET`, `session_id`; PLAY-2), `session_turn` (`POST`, `session_id`; API-2, API-3), `session_messages` (`GET`, `session_id`; PLAY-3, PLAY-4), and `session_message` and `session_message_status` (`GET`, `session_id` and `message_id`; PLAY-4). > > 21. Runs: `workflow_run` (`POST`, `workflow_id`; MAN-13, MAN-15, VAL-LAUNCH, API-10), `workflow_pipelines` (`GET`, `workflow_id`; API-12), `pipeline` and `pipeline_status` (`GET`, `pipeline_id`; PIPE-1), `pipeline_jobs` and `pipeline_job_status` (`GET`, `pipeline_id`; PIPE-5), `pipeline_logs` (`GET`, `pipeline_id`; no rule yet defines its answer), `job` (`GET`, `job_id`; PIPE-5, PIPE-7), and `pipeline_cancel`, `pipeline_pause` and `pipeline_resume` (`POST`, `pipeline_id`; INT-16). > > 22. Interrupts: `interrupt_resolve` (`POST`, `interrupt_id`; INT-3), `interrupt_callback` (`POST`, `interrupt_id`; INT-19) and `interrupt_cancel` (`POST`, `interrupt_id`; INT-24). > > 23. Snapshots: `snapshots` (`GET`, no variables; SNAP-1, SNAP-2), `snapshot` (`GET`, `execution_id`; SNAP-1, SNAP-2), `snapshot_save` (`POST`, no variables; SNAP-1) and `snapshot_delete` (`DELETE`, `execution_id`; SNAP-1, SNAP-2). > > 24. A query parameter a rule defines is added by the client as that rule says. > > 25. Other rules define further members of the document. > > 26. The document MUST be the same for every caller. > > 27. It MUST NOT carry tenant data, credentials or the implementation's software version. > > 28. Listing a route in the document MUST NOT change how that route is authorised. > > 29. A client MUST NOT send a request to a template that is not path-absolute, or whose resolved URL lies outside the discovery document's origin. ## What it means The rules talk about routes by what they do: the launch, a run's status document, the signal API, the callback route. None of them says where a route lives, and none should, because an implementation's URL space is its own. What a client that drives several implementations needs is a way to ask each one. That is this document: one `GET`, and every route the client may call comes back as a name and a template. A route name carries more than a path. It fixes the method, and it fixes the names of the template's variables, so a client that knows `pipeline_cancel` knows it is a `POST` and that it fills in `{pipeline_id}`. What the route answers is still the business of the rules that define it; the document only says where to send the request. A route that is missing from `endpoints` is a route the implementation does not serve, which a client learns without trying it. Templates are level 1 and path-absolute, which keeps them safe to expand, with one exception the rule closes. Level 1 percent-encodes every character outside the unreserved set, so an identifier holding a `/` cannot add a path segment. But `.` and `..` are made only of unreserved characters, so they pass unencoded, and resolving the expanded URL removes them as dot-segments: `snapshot_delete` expanded with `..` would send a `DELETE` one level up from the snapshot. So no identifier is ever `.` or `..`, and a client refuses to expand a template with either. Path-absolute means the template starts with a single `/` and is resolved against the discovery URL, so it stays on that origin. A client still refuses a template that would leave it: a document that pointed a route at another host would make the client send its credentials there. The URL templates resolve against is the one the client asked for. A redirect of the discovery request to another origin is not followed: the document it led to could point every route at that origin, which is exactly what the origin check is there to stop. `/.well-known/flowdrop` is the default, not the only place. An implementation mounted under a sub-path, or one of several sharing an origin, cannot own that path, so it hands its clients the discovery URL instead, and every client accepts one. Templates resolve against whichever URL the document was read from, so the same document works in both cases. The document is the same for every caller and carries nothing about any of them: no tenant data, no credentials, no software version. Since it holds nothing secret, it is served without asking who is calling; a client can read it before it has signed in to anything. It is a plain `application/json` object rather than an answer in the `{success, data}` envelope: it is not the result of an operation that could be refused, and a well-known metadata document is read as the document itself. It is a map, not a gate; whether a caller may use a route is decided by that route, exactly as if the map did not exist. Other rules add members of their own where a client needs to know a capability before it calls a route. ## Example ```http title="Asking an implementation where its routes are" verdict="200 discovered" GET /.well-known/flowdrop {"endpoints": { "workflow_run": "/api/flowdrop/workflow/{workflow_id}/run", "workflow_pipelines": "/api/flowdrop/workflow/{workflow_id}/pipelines", "pipeline": "/api/flowdrop/pipeline/{pipeline_id}", "pipeline_status": "/api/flowdrop/pipeline/{pipeline_id}/status", "pipeline_cancel": "/api/flowdrop/pipeline/{pipeline_id}/cancel", "interrupt_callback": "/api/flowdrop/interrupts/{interrupt_id}/callback" }} ``` This implementation serves no snapshot routes and no log route, so those keys are absent. A client that wants to cancel run `4711` expands `pipeline_cancel` to `/api/flowdrop/pipeline/4711/cancel`, resolves it against the discovery URL, and sends a `POST`. ```json title="A template a client must not follow" verdict="refused by the client" {"endpoints": {"pipeline": "//elsewhere.example/pipeline/{pipeline_id}"}} ``` That template is not path-absolute: resolved, it names another host. Every path shown on the other pages of this specification is an example of the route it names, never a requirement. Every route a rule defines has a name, grouped by what it serves: workflows, sessions, runs, interrupts and snapshots. `pipeline_logs` is the one name whose answer no rule defines yet. It is kept because a name only says where a route is, and a client that shows a run's log can find it on any implementation; a rule that defines the log's answer can follow without renaming anything. ## Why Recorded under [OPEN-51](https://flowdrop.io/spec/rulings/open-51). ## References **Normative** — incorporated into this rule: - RFC 8615, Well-Known Uniform Resource Identifiers (URIs) (https://www.rfc-editor.org/rfc/rfc8615) — The `/.well-known/` path prefix and its meaning, which the document's default location uses. - RFC 6570, URI Template (https://www.rfc-editor.org/rfc/rfc6570) — The template syntax and level 1 (simple string expansion), which percent-encodes every character outside the unreserved set, so a value holding `/` cannot add a path segment. `.` and `..` are made of unreserved characters and pass unencoded, which is why the rule forbids them as values. - RFC 3986, Uniform Resource Identifier (URI): Generic Syntax (https://www.rfc-editor.org/rfc/rfc3986) — What path-absolute means (section 3.3), how a reference is resolved against a base URL (section 5), and how resolution removes the dot-segments `.` and `..` (section 5.2.4). ## Related rules - Names: API-8, PIPE-1, PIPE-5, INT-16, INT-19, INT-24, SNAP-1, API-11, API-12 - Referenced by: STORE-14, INT-24, API-10, API-11, API-12 --- Rule identifiers are permanent and are never renumbered. This specification carries no implementation status: each implementation publishes its own standing against these rules. Licensed CC BY 4.0.