ForLoop Search integration guide
ForLoop core service · docs
v1.0.0
llms.txtOpen console

ForLoop core service

ForLoop Search integration guide

Run web search and page fetch for a ForLoop app with cache-first results, per-app limits, and per-success billing.

Quickstart

Create an app-subject connection to this service, then exchange the app credential for an assertion.

curl -X POST https://search.app.forloop.cc/api/opencode/a2a/connections/<connectionId>/assertion \
  -H "x-api-token: $FLC_APP_CREDENTIAL" \
  -H "content-type: application/json" \
  -d '{"scopes":["search.queries:write"],"contractVersion":"1.0.0"}'

The assertion is valid for 300 seconds. Send it as Authorization: Bearer <assertion> on every /v1 call.

  1. Send POST /v1/search with a query and result count.
  2. Read the ranked results or the cached response.
  3. Send POST /v1/fetch with a public http(s) URL.
  4. Read GET /v1/usage for searches, fetches, cache hits, and charges.

Authentication and tenancy

The service trusts only a verified app assertion. It checks iss, aud, sub=app:<callerSprintId>, appPublicId, env, scopes, and the pinned contractVersion.

Scopes

API reference

MethodPathAccessSuccessToolPurpose
POST/v1/searchwrite200Web searchSearch the live web for a query and return ranked, normalized results. Provider-specific field names never appear in the response. The call returns a stable searchId, a cached flag, the normalized results, and billing state. Requires an Idempotency-Key header.
POST/v1/fetchwrite200Web fetchFetch one HTTP(S) page through the platform provider and return normalized Markdown content. The response includes a stable fetchId, cached flag, title, content metadata, truncation flag, and billing state. Requires an Idempotency-Key header.

POST /v1/search · write · success 200

Search the live web for a query and return ranked, normalized results. Provider-specific field names never appear in the response. The call returns a stable searchId, a cached flag, the normalized results, and billing state. Requires an Idempotency-Key header.

Example

POST /v1/search
Idempotency-Key: research-query-1
Authorization: Bearer <assertion>
{"query":"DeepSeek site:github.com lang:en","count":10,"needContent":false}

200
{"searchId":"srch_01J...","status":"ok","cached":false,"query":"DeepSeek site:github.com lang:en","count":10,"results":[{"rank":1,"title":"DeepSeek V4 model released","url":"https://example.com/deepseek-v4","snippet":"DeepSeek V4 is now available...","summary":"DeepSeek has released the V4 model...","content":null,"siteName":"Example News","siteIcon":"https://example.com/favicon.ico","publishedAt":"2026-06-01T00:00:00Z","authority":3,"relevanceScore":2.4}],"resultCount":1,"billing":{"state":"charged","quotedAmountFLC":2,"chargedAmountFLC":2,"catalogVersion":"1","settlementId":"stl_srch_01J..."},"contractVersion":"1.0.0","createdAt":"2026-11-03T12:00:00Z"}

Output fields: searchId, status, cached, query, count, results, resultCount, billing, contractVersion, createdAt

Web fetch

POST /v1/fetch · write · success 200

Fetch one HTTP(S) page through the platform provider and return normalized Markdown content. The response includes a stable fetchId, cached flag, title, content metadata, truncation flag, and billing state. Requires an Idempotency-Key header.

Example

POST /v1/fetch
Idempotency-Key: fetch-article-1
Authorization: Bearer <assertion>
{"url":"https://example.com/article","noCache":false}

200
{"fetchId":"fch_01J...","status":"ok","cached":false,"url":"https://example.com/article","title":"Example article","content":"# Example article\n\nArticle content.","contentType":"text/markdown","contentBytes":1234,"truncated":false,"billing":{"state":"charged","quotedAmountFLC":2,"chargedAmountFLC":2,"catalogVersion":"1","settlementId":"stl_fch_01J..."},"contractVersion":"1.0.0","createdAt":"2026-11-03T12:00:00Z"}

Output fields: fetchId, status, cached, url, title, content, contentType, contentBytes, truncated, billing, contractVersion, createdAt

Errors and retries

CodeMeaningRetry?
invalid_assertion / expiredThe assertion is missing, invalid, or expired.No; exchange a fresh assertion.
insufficient_scopeThe assertion does not carry a required scope.No; update the connection grant.
env_mismatch / audience_mismatchWrong platform environment or target.No; fix the connection.
invalid_requestThe request body or parameters are invalid.No.
not_foundThe resource is absent or belongs to another app.No.
conflictVersion, state, or idempotency conflict.No; read the current state first.
quota_exceeded / rate_limitedPer-app quota or rate limit reached.Yes, after the indicated delay.
internal_error / provider_transportTransient platform or provider failure.Yes, with backoff and the same idempotency key.

Billing

undefined FLC per 1 unit (ceil). Payer: APP:<appPublicId>. Failures are free.

The service reserves before billable work and commits only after the success condition in its contract. A failed, filtered, or canceled unit is free. A successful unit that cannot settle is retried durably and is never silently released.

Limits and retention

AI-agent checklist

  1. Discover the target agent card and pin its exact contract version.
  2. Exchange the app credential for a fresh assertion immediately before the call.
  3. Use the generated client types; never hand-write a response type.
  4. Send Idempotency-Key on every write and reuse it only for the same logical request.
  5. Never infer the payer or app ID from a request body; use the verified assertion.
  6. Treat 4xx errors as terminal unless the contract explicitly says otherwise; retry only transient 5xx/transport errors with backoff.
  7. Read the returned job/delivery state before presenting success to a user.