# GLODA API — skill guide

GLODA indexes jobs, tenders, grants, and signals in international development as structured,
source-backed records, and answers questions over that corpus with citations. This file tells an
LLM agent or tool how to use the public v1 API correctly.

Machine-readable spec: **https://gloda.org/api/v1/openapi.json** (OpenAPI 3.1).

## Authentication

Every request needs an API key, created by the account owner in Account → API keys (API access is a
plan capability). Send it as either header:

- `Authorization: Bearer <key>`
- `x-api-key: <key>`

Keep the key server-side. Never put it in client-side code, a URL, or anything a user can see.

## Endpoints

### GET /api/v1/items/search

Search the corpus. Common query parameters (comma-separated where plural):

- `q` — full-text query
- `type` — job, tender, grant, signal
- `countries` — ISO country codes; `regions`; `tags`
- `funders`, `sectors`, `lifecycle`, `valueMin`, `valueMax` — tender filters
- `grantFunders`, `grantStatus` (forecast|open|closed|archived), `grantAmountMin`, `grantAmountMax`, `grantRecurrence` (annual|biennial|rolling|multi-cutoff|one-off — the programme's computed recurrence; each grant carries a `grant_program` summary with `recurrence`, `recurrenceBasis`, `typicalOpenMonth`, `callCount` and evidence ids, open on every plan) — grant filters
- `grades` (intern|entry|mid|senior|lead|director|executive), `contractTypes` (fixed-term|temporary|permanent|consultant|internship|fellowship|volunteer), `remote` (onsite|hybrid|remote|home-based), `orgTypes` (un|mdb|bilateral|ingo|ngo|foundation|government|private|academic), `languages` (ISO-639-1), `salaryMin`/`salaryMax` (annualised USD) — job filters, free on every plan; each job carries a `job_details` block (grade, contract type, duty station, remote eligibility, salary with FX evidence, required languages)
- `recordLanguage` (ISO-639-1, comma list, e.g. `recordLanguage=fr,pt`) — language the notice is published in, every pillar, free on every plan; each item carries `language_code` + `language_source` (`source` = the publisher states it, `detected` = GLODA's deterministic detector). Record text is never translated. Not to be confused with `languages` (languages a JOB requires)
- `q` runs a curated, deterministic four-language synonym expansion (e.g. `assainissement` also searches `sanitation`, `saneamiento`, `saneamento`, `WASH`); the response's `query_expansion` lists `{ matched, canonical, also_searched }` for every expansion applied (`[]` when none). Unknown terms are searched exactly as typed
- `publishedFrom`/`publishedTo`, `deadlineFrom`/`deadlineTo` — ISO 8601 dates
- `deadlineWithinDays` — deadline within the next N days (1–366), resolved when the query runs; ignored when an absolute deadline bound is set
- `page`, `pageSize` (max 200), `sort`, `cursor`

Response: `{ ok, total, page, pageSize, items[], facets, next_cursor, apiScope }`. Fields a key's
plan cannot see are redacted (null/empty) before the response — the API never widens access.

### GET /api/v1/answers

Ask a plain-language `question` (max 400 chars). A model compiles it into a structured query; the
query runs deterministically against the corpus. Response: `{ ok, plan, summary, rows, citations }`,
or `{ ok, question, unsupported }` when the corpus cannot support an answer. **It returns
`unsupported` rather than guessing — treat `unsupported` as a real, correct answer, not an error.**

### GET /api/v1/recompetes

Recompete windows — contracts coming up for rebid. A window exists only where the source STATES a
contract end date, or a contract start plus a duration (`completeness` says which); window = stated
end − 183 days to + 92 days. Nothing is estimated, and there is no probability of a rebid.
Parameters (comma-separated where plural): `horizon` (3|6|12|24 months, default 12), `funders`,
`countries`, `sectors`, `buyers`, `incumbents` (entity ids), `status` (upcoming|open|closing|matched),
`minValue` (USD), `page` (50 rows). Response: `{ ok, recompetes: { rows[], total, page, facets,
quarters, rule, ruleStats, excludedNoBasis } }`; each row carries its evidence award, contract,
participants, the incumbent as published (`linked: false` when not tied to an entity) and any
advertised notice that matched the window. `ruleStats` is the honesty line for the rule: per funder,
how many finished windows saw a notice (`matched` of `decided`). Needs award context (Professional
and above) on the key's plan as well as API access; otherwise `403` with code `entitlement_required`.

## Pagination

Use `page`/`pageSize` for shallow reads; the offset is capped at 10,000. To traverse deeply on a
date sort (`published_at_desc`/`asc`, `created_at_desc`), take `next_cursor` from each response and
pass it back as `cursor` — a stable keyset that stays cheap at any depth. A `null` `next_cursor`
means the end of the results.

## Limits and headers

- Search: 60 requests/minute. Answers: 20 requests/minute (each spends a model call).
- Per-key daily quota where the plan sets one; over-limit returns `403` with code `api_daily_limit`.
- Every response carries `X-RateLimit-Limit`/`Remaining`/`Reset`, `X-Api-Daily-Used`/`Limit`, and
  `X-Api-Tier` (the plan tier that served the request). Pace against these headers rather than
  retrying blindly.

## Errors

All errors share one envelope: `{ ok: false, error: "<message>", code?: "<machine code>" }`. Notable
codes: `api_daily_limit`, `rate_limited` (per-minute limit; back off for `retryAfterSeconds`),
`offset_cap` (switch to `cursor`), `invalid_cursor` (re-request without `cursor` and follow
`next_cursor`), `answers_daily_cap`.

## MCP server

GLODA also speaks the Model Context Protocol, so Claude Desktop, Claude Code and Cursor can use the
corpus as tools. Endpoint: **`POST https://gloda.org/api/mcp`** (streamable HTTP, stateless). It uses
the same API key as the REST API — send `Authorization: Bearer <key>` (or `x-api-key`). A missing or
invalid key returns a JSON-RPC `unauthorized` error; a key whose plan lacks API access returns
`forbidden` with an `upgrade_url`.

Read-only tools:

- `search_items` — the v1 search as a flat argument object (`q`, `type[]`, `countries[]`, `funders[]`,
  `sectors[]`, `lifecycle[]`, `valueMin`/`valueMax`, `grantFunders[]`, `grantStatus[]`,
  `grantAmountMin`/`Max`, `grantRecurrence[]`, `grades[]`, `contractTypes[]`, `remote[]`, `orgTypes[]`, `languages[]`, `recordLanguage[]`,
  `salaryMin`/`Max`, `publishedFrom`/`To`, `deadlineFrom`/`To`, `deadlineWithinDays`, `sort`,
  `pageSize` ≤ 50, `cursor`); returns redacted items with `record_url` and `next_cursor`.
- `get_item` — one record by `id`, redacted, with provenance and `record_url`.
- `get_entity_profile` — `{ kind: buyer | contractor | funder, slug }`; suppressed metrics stay
  suppressed (a note, not a number).
- `list_coverage` — the live / configured-not-live / tracked source split with method, cadence, last
  success and record count.

Resources: `gloda://skill`, `gloda://openapi`, `gloda://methodology`. Prompt: `qualify_tender`. Each
tool call counts against the same per-minute limit and per-key daily quota as the REST API; over-limit
tool results carry `rate_limited` / `api_daily_limit` with `retryAfterSeconds`.

## Organisation provisioning

Enterprise and Team Professional organisations can manage seats from an identity provider or a
script. Mint an **organisation key with the `provisioning` scope** in Account → Team → Organisation
controls → Provisioning (owners and admins only). That key works only on these endpoints and cannot
read the corpus; ordinary keys cannot provision.

- `GET /api/v1/org/members` — members and pending invites, plus `seats: { limit, used }` (`limit: null` =
  unlimited).
- `POST /api/v1/org/members` `{ "email": "...", "role": "MEMBER" | "ADMIN" }` — adds the person directly
  when the organisation uses single sign-on for that email domain (`mode: "member"`), otherwise emails
  an invite (`mode: "invite"`). Over the plan's seats: `409` with `code: "seat_limit"` and
  `details: { limit, used }`.
- `PATCH /api/v1/org/members/{id}` `{ "role": "OWNER" | "ADMIN" | "MEMBER" }`.
- `DELETE /api/v1/org/members/{id}` — removes a member (their sessions and their organisation API keys
  are revoked) or cancels an invite. The last owner cannot be removed (`owner_required`).

Every call is written to the organisation's audit log with the key id. A key stops working when its
owner is no longer an owner or admin of the organisation.

## Honesty contract

Records carry provenance (source, fetched-at, revision history); sectors disclose how they were
derived; USD values disclose approximate conversions. Cite the original publisher as the source and
GLODA as where the record was accessed. GLODA is not affiliated with the funders whose public
records it indexes.
