Backend quickstart
Submit a reproducible service request, observe live progress and retrieve its final result with Node.js 22.18 or newer and built-in Fetch. No unpublished SDK package is required.
1. Prepare a service and identity
An administrator prepares an active workspace Agent binding, Codex Harness and an admissible Environment. The first example needs neither a repository nor tools. Agent instructions should accept a text field in structured input and answer it.
Create an Agent service whose input schema requires a text string. Follow service publication with service.json. Record the returned deployment id, not an Agent ID, workspace ID or revision number.
Register a confidential OAuth client for that project with invocations:read invocations:write, and obtain an access token using the authentication guide. A suitably scoped API Token also works for debugging; provide its tenant header when required.
2. Submit through HTTP
Persist the business request and idempotency key in your own job record before POST. This key is illustrative; use a new key for new business work.
export ORBITSPACE_API_URL=https://api.orbitspace.dev
export ORBITSPACE_DEPLOYMENT_ID=REPLACE_WITH_DEPLOYMENT_ID
export ORBITSPACE_REQUEST_KEY=proposal-review-job-001
curl --fail-with-body \
"$ORBITSPACE_API_URL/api/v1/agent-deployments/$ORBITSPACE_DEPLOYMENT_ID/invocations" \
-H "Authorization: Bearer $ORBITSPACE_ACCESS_TOKEN" \
-H "Idempotency-Key: $ORBITSPACE_REQUEST_KEY" \
-H 'Content-Type: application/json' \
-d '{"input":{"text":"Explain three checks for reviewing a project proposal. Do not use tools."}}'Save id, deployment_revision_id, status and state_version from the response. HTTP success returns an Invocation record; execution can already be complete or still queued, running or waiting.
3. Run the complete example
Save these three source files in one directory. No npm installation is needed:
- quickstart.mjs: submission, subscription and result retrieval.
- api-client.mjs: authenticated HTTP and bounded reconnection.
- sse.mjs: chunked UTF-8, comments and multiline SSE framing.
Inject ORBITSPACE_ACCESS_TOKEN using your secret-management mechanism. Do not put the credential into source code or commit it. Then configure the service and persisted request key:
export ORBITSPACE_DEPLOYMENT_ID=REPLACE_WITH_DEPLOYMENT_ID
export ORBITSPACE_REQUEST_KEY=proposal-review-job-002
node quickstart.mjsThe program prints the Invocation ID, status, progress and final output. It exits with 0 for INVOCATION_STATUS_COMPLETED and 2 for failed, cancelled or unfinished work. Its five-minute observation deadline does not cancel platform execution; use the recorded Invocation ID to inspect it later.
4. Present the business result
Read output, output_artifact_ids, error_code and usage from GET /api/v1/invocations/{id}. An empty output schema does not guarantee a particular business field. Define and validate a result contract before requiring structured output.
Update your own job only after validating the result. For files, follow the Artifact download flow; a download receipt is JSON metadata, not the file itself.
5. Recover and extend
After a lost POST response, reuse the same service, exact input and persisted key. Read current state before cancellation or failed-request retry. Follow the interaction boundary for approval or input waits.
This example validates the protocol connection. Production also requires business-job ownership checks, persistence, Webhook ingestion, quotas and result validation. See the production checklist.