> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gloo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Procedure SDK for Python

> Current gloo_procedure_sdk exports and procedure-sandbox usage.

`gloo_procedure_sdk` is preinstalled in a Forge Python procedure sandbox. Networked helpers are
async. Importing the package installs its egress guard when `GLOO_EGRESS_POLICY` is present; the
guard is a no-op when that policy is absent.

## Root exports

| Area | Exports |
| - | - |
| Capabilities | `invoke_capability` |
| Knowledge | `knowledge_list`, `knowledge_get`, `knowledge_search` |
| Files and composition | `put_file`, `get_file`, `run_procedure` |
| Progress | `emit_progress` |
| Session | `read_session`, `ProcedureSession`, session errors and Freshservice delivery types |
| Structured choice | `choose_values` and its rule/evidence/result/invoker types |
| Deterministic selection | `select_candidate` |
| Effects | `record_sandbox_effect` (qualification fixture use only) |
| Egress and errors | `install_egress_guard`, `EgressGuardError`, `ProcedureApiError`, `proxy_call`, `to_procedure_error_envelope` |
| Contract | `PROCEDURE_ERROR_CODES` |

## Call a capability

```python theme={null}
from gloo_procedure_sdk import invoke_capability

result = await invoke_capability(
    "network",
    "fetch",
    {"url": "https://example.com/", "method": "GET", "timeoutMs": 10_000},
)
response = result["data"]
print(response["status"], response["body"])
```

The manifest must declare `network`, and dispatch must grant the session that domain and the `fetch` operation. Use an approved URL for the procedure's task. The platform proxy resolves the network provider and records the call. Its normalized response has `status`, `headers`, and `body`; JSON content is decoded and other content is returned as text. The capability performs one request without retrying it. Vendor secrets must not be embedded in these arguments.

For direct Linear pagination, use the [Vendor Connection procedure](https://docs.gloo.com/forge/build/built-in-procedures.md#linear-paginate-issues), not an invented `linear` capability domain.

## Read knowledge

Knowledge helpers are async and return refusal/completeness states that author code must inspect.
The manifest must declare the `knowledge` capability and required permission. Do not treat a
partial or stale list as complete.

```python theme={null}
groups = await knowledge_list(["freshservice.group"], source_id=source_id)
if groups["status"] != "complete":
    raise RuntimeError(f"knowledge unavailable: {groups['reason']}")
```

## Files, composition, and progress

`put_file`, `get_file`, and `run_procedure` are async. Use sandbox/file modes for large binary
inputs rather than loading them as text. Prefer a workflow edge over `run_procedure` when operators
need to see the composition. `emit_progress` is synchronous and best-effort.

## Choice and selection helpers

`choose_values` evaluates a bounded caller-owned menu through the typed-judgment capability and
returns validated probability evidence under caller-supplied acceptance rules. It does not retry or
perform the resulting effect. `select_candidate` is local and deterministic over opaque ids; it
performs no provider I/O.

## Session and errors

`read_session()` parses the injected signed session. Some dedicated registered procedures can use
its Freshservice reservation/terminal methods; those methods are not general ticket-send authority.
`to_procedure_error_envelope` produces a bounded safe error shape.

Branch on `ProcedureApiError.code` and the exported closed `PROCEDURE_ERROR_CODES`, not message text.
Some codes originate in platform preflight, polling, or enforcement outside the sandbox.

See [Author a procedure](https://docs.gloo.com/forge/build/author-a-procedure.md) and [Node SDK](https://docs.gloo.com/forge/reference/procedure-sdk-node.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.