Agent integration guide
A step-by-step plan an AI agent can follow to integrate an application without help.
This page is written for an agent operating a terminal with network access. Follow the steps in
order; each has a verification command. Everything is scriptable through the CLI (--json) or
the OpenAPI document.
Plan
- Get credentials. If the user has an account, ask for a personal access token (
opat_…) and the environment id; otherwise runorishare signup … --save. Verify withorishare --json whoami. - Pick the sandbox. Never integrate against production first.
orishare --json environments --project proj_…lists both; keep thesandboxid inORISHARE_ENVIRONMENT. - Mint a server key.
orishare --json keys create --environment $ORISHARE_ENVIRONMENT --name app. Store theosk_test_…token in the application's secret store. Browser or mobile code gets a publishable key instead (--kind publishable), which can only send events you explicitly allow. - Model the events. List the business moments that should earn or unlock something
(
order.paid,lesson.completed,referral.converted). Send one of each withorishare events send … --sync, then runorishare --json schema show: Orishare records the observed property schema per event name. - Write the rules. One JSON document per behavior (see Rules). Use
limits for "once per X" semantics rather than conditions on history. Create with
rules create --file, check withrules simulate, then--publish. - Programs. Add a tier program, rewards or challenges only when the rules need them
(
orishare api post /tier_programs …). Reference rewards by id inreward.issueactions. - Wire the application. Server side:
POST /v1/eventswith the secret key after each business moment, idempotent by the eventidyou supply (retries are safe). ReadGET /v1/customers/{id}/stateto render balances and tiers. Client side: publishable key,anonymous_idbefore login, and acustomer_tokenfromPOST /customers/{id}/client_tokenafter login. - Webhooks. Register an endpoint (
orishare api post /webhook_endpoints), store the secret shown once, verifyOrishare-Signature(verifyWebhookSignaturein the client library) and send a test withorishare api post /webhook_deliveries --data '{"endpoint_id":"whe_…"}'. - Promote.
orishare config pullfrom the sandbox,orishare --env env_prod… config push --file …to preview the diff, then--apply. Rules are published in production only by owners and admins. - Verify end to end in production with one real event and
customers state.
Rules of thumb
- Every creating
POSTneeds anIdempotency-Key; the CLI and client library add one. - Every response error has
type,code,message,param,request_id; the codes are listed at /errors and never change meaning. Retry429afterRetry-After, never retry409 stale_writeblindly: re-read the resource and send the newIf-Match. - Sync evaluation may fall back to async under load (
202withfallback: true); pollGET /events/{id}untilstatusisevaluated. - Sandbox data is free and metered for quotas only; production customers are billed.
POST /ai/rule_drafts(CLIai draft) returns validated rule documents with assumptions, or422 ai_draft_rejectedwith the questions to answer; it never publishes. Create the rule withai_generation_idset so the draft stays linked to the version it becomes.GET /customers/{id}/export(CLIcustomers export) answers access and portability requests in one document;DELETE /customers/{id}redacts and keeps only the ledger history.