Kosmobids Public API

Saved searches and matching runs

Create persistent search criteria, trigger asynchronous matching, and poll the matches a run produced.

A saved search is a named set of criteria and options. A matching run evaluates the saved search against the tender corpus and records the matches it finds. Runs are asynchronous.

Saved search CRUD

Method Path Purpose
GET /saved-searches List the company's saved searches.
POST /saved-searches Create a saved search.
GET /saved-searches/:savedSearchId Read one saved search.
PATCH /saved-searches/:savedSearchId Update name, criteria, or options.
DELETE /saved-searches/:savedSearchId Soft-delete a saved search.
{
  "name": "Cloud migration in DACH",
  "criteria": {
    "includeKeywords": ["cloud migration", "managed services"],
    "contractingCountry": ["DE", "AT", "CH"],
    "submissionDeadlineAtLeastDays": 14
  },
  "options": {
    "type": "mixed",
    "recommendedFilter": "all"
  }
}

A company can hold up to 10 saved searches. Creating an 11th returns 409. A saved search that belongs to another company returns 404 for read, update, and delete.

Trigger a run

POST /saved-searches/:savedSearchId/runs

{
  "publishMatches": false,
  "evaluationPrompt": "Optional override for this run",
  "includeCompanyDescription": true
}
Field Default Meaning
publishMatches false Keep matches as previews. Set to true to publish qualifying matches to the company pipeline.
evaluationPrompt saved-search option Override the evaluation prompt for this run.
includeCompanyDescription saved-search option Include the company description in evaluation prompts.

The response is:

{
  "data": {
    "runId": "workflow-id",
    "workflowId": "workflow-id",
    "status": "new"
  },
  "error": null
}

runId and workflowId both identify the run workflow. Store one of them; they are currently the same value.

Run lifecycle

Status Final? Meaning
new No The run was accepted and is waiting to start.
in_progress No Matching is running.
done Yes The run finished. Matches are available.
error Yes The run failed. Retry by triggering a new run.

List runs

GET /saved-searches/:savedSearchId/runs?limit=50&offset=0

Runs are returned newest first. limit is 1–100 and defaults to 50; offset defaults to 0. The response contains runs and total.

{
  "data": {
    "runs": [
      {
        "id": "run-record-id",
        "searchProfileId": "saved-search-id",
        "companyId": "company-uuid",
        "runId": "workflow-id",
        "tag": "api-trigger",
        "triggerSource": "api",
        "status": "done",
        "created_at": "2026-11-06T08:00:00.000Z"
      }
    ],
    "total": 1
  },
  "error": null
}

List run matches

GET /saved-searches/:savedSearchId/runs/:runId/matches

Query parameters:

Parameter Meaning
fit Comma-separated match, industry_match, or not_match.
limit 1–500, default 25.
offset Number of matches to skip, default 0.
{
  "data": {
    "runId": "workflow-id",
    "searchProfileId": "saved-search-id",
    "status": "done",
    "isFinalStatus": true,
    "matchScores": [
      {
        "id": "match-score-id",
        "tender_id": "0f8fad5b-d9cb-469f-a165-70867728950e",
        "company_id": "company-uuid",
        "evaluation": { "fit": "match", "reasoning": "...", "origin": ["cpv"] },
        "finalScore": { "score": 4, "reasoning": "...", "reasoning_short": "...", "warnings": [] },
        "created_at": "2026-11-06T08:10:00.000Z"
      }
    ],
    "count": 1,
    "total": 18
  },
  "error": null
}
  • count is the number of items in this page.
  • total is the number of matches that satisfy the filter.
  • isFinalStatus is true when status is done or error.

A 404 means the saved search or run does not exist or belongs to another company.

Polling pattern

  1. Trigger the run and keep the returned runId.
  2. Poll GET /saved-searches/:savedSearchId/runs/:runId/matches with a backoff.
  3. Stop when isFinalStatus is true.
  4. Page through the matches with offset while offset + count < total.
async function waitForRun(savedSearchId: string, runId: string) {
  let delay = 2_000;
  for (let attempt = 0; attempt < 60; attempt++) {
    const response = await fetch(
      `${BASE_URL}/saved-searches/${savedSearchId}/runs/${runId}/matches?limit=100`,
      { headers: { 'x-api-key': process.env.KOSMOBIDS_API_KEY! } },
    );
    const body = await response.json();

    if (body.data.isFinalStatus) {
      if (body.data.status === 'error') throw new Error('Matching run failed');
      return body.data;
    }

    await new Promise((resolve) => setTimeout(resolve, delay));
    delay = Math.min(delay * 2, 30_000);
  }
  throw new Error('Timed out waiting for the matching run');
}

Do not poll faster than once per second. A run can take minutes to tens of minutes depending on the corpus and the number of candidates.