# SAM.gov API

> SAM.gov returns federal contract notices and related details as a workflow and API.

SAM.gov returns federal contract notices through Search contract opportunities, which requires keywords. Optional inputs filter by agency, state, set-aside, notice type, and posting period. Results include notice details such as agency, industry, posting date, deadline, and performance location; award notices are included when selected.

- Page: https://fous.com/workflows/sam-gov
- Handle: `@sam-gov`
- Category: [Government](https://fous.com/workflows/category/government)
- Source website: https://sam.gov
- Last verified: Sep 29, 2026
- Fous is not affiliated with SAM.gov.

## Methods

### Search contract opportunities

Operation `search_contract_opportunities`, version 1. 1 credit per call.

Find active federal contract notices matching keywords, agency, place of performance, set-aside, notice type, and posting period. Results include award notices when selected; fields not published on a notice are null.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `state` | string | no | `"TX"` | Place-of-performance state, such as Texas or TX. |
| `agency` | string | no | `"Department of Veterans Affairs"` | Federal agency name, such as Department of Veterans Affairs. |
| `keywords` | string | yes | `"janitorial services"` | Words to search for, such as janitorial services. |
| `set_aside` | string | no | `"hubzone"` | Business preference, such as hubzone. |
| `max_results` | integer | no | `5` | Maximum notices to return, such as 25. |
| `notice_type` | string | no | `"solicitation"` | Kind of notice, such as solicitation. |
| `posted_within_days` | integer | no |  | Only notices posted within this many days, such as 30. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "keywords"
  ],
  "properties": {
    "state": {
      "type": "string",
      "description": "Place-of-performance state, such as Texas or TX.",
      "examples": [
        "TX"
      ]
    },
    "agency": {
      "type": "string",
      "description": "Federal agency name, such as Department of Veterans Affairs.",
      "examples": [
        "Department of Veterans Affairs"
      ]
    },
    "keywords": {
      "type": "string",
      "minLength": 1,
      "description": "Words to search for, such as janitorial services.",
      "examples": [
        "janitorial services",
        "cybersecurity"
      ]
    },
    "set_aside": {
      "enum": [
        "any",
        "small_business",
        "women_owned",
        "veteran_owned",
        "service_disabled_veteran_owned",
        "hubzone",
        "8a"
      ],
      "type": "string",
      "default": "any",
      "description": "Business preference, such as hubzone.",
      "examples": [
        "hubzone"
      ]
    },
    "max_results": {
      "type": "integer",
      "default": 25,
      "maximum": 100,
      "minimum": 1,
      "description": "Maximum notices to return, such as 25.",
      "x-fous-developer": true,
      "examples": [
        5,
        3
      ]
    },
    "notice_type": {
      "enum": [
        "any",
        "solicitation",
        "presolicitation",
        "sources_sought",
        "combined_synopsis",
        "award_notice"
      ],
      "type": "string",
      "default": "any",
      "description": "Kind of notice, such as solicitation.",
      "examples": [
        "solicitation"
      ]
    },
    "posted_within_days": {
      "type": "integer",
      "default": 30,
      "maximum": 365,
      "minimum": 1,
      "description": "Only notices posted within this many days, such as 30.",
      "x-fous-developer": true
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "state": "TX",
      "keywords": "janitorial services",
      "set_aside": "hubzone",
      "max_results": 5,
      "notice_type": "solicitation"
    },
    {
      "keywords": "janitorial services"
    },
    {
      "agency": "Department of Veterans Affairs",
      "keywords": "janitorial services",
      "max_results": 5
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `opportunities` | array |  |  |
| `opportunities[].link` | string or null | `"https://sam.gov/workspace/contract/opp/68a0912bb79e4c43b3bb5085e50aff3b/view"` | SAM.gov notice page |
| `opportunities[].title` | string or null | `"Fort Hood Installation Custodial Services"` | Notice title |
| `opportunities[].agency` | string or null | `"DEPT OF DEFENSE"` | Federal agency |
| `opportunities[].office` | string or null | `"W6QM MICC-FDO FT CAVAZOS"` | Contracting office |
| `opportunities[].industry` | string or null | `"Janitorial Services"` | Industry name |
| `opportunities[].notice_id` | string or null | `"68a0912bb79e4c43b3bb5085e50aff3b"` | SAM.gov notice ID |
| `opportunities[].set_aside` | string or null | `"HUBZone Set Aside"` | Business set-aside name |
| `opportunities[].naics_code` | string or null | `"561720"` | NAICS code |
| `opportunities[].notice_type` | string or null | `"Solicitation"` | Notice type |
| `opportunities[].posted_date` | string or null | `"2026-09-25"` | Posting date in YYYY-MM-DD |
| `opportunities[].response_deadline` | string or null | `"2026-10-07T10:00:00-05:00"` | Response deadline with time zone |
| `opportunities[].solicitation_number` | string or null | `"W91151-26-R-A004"` | Solicitation number |
| `opportunities[].place_of_performance` | string or null | `"Fort Hood, Texas, UNITED STATES"` | Performance location |

**Example input**

```json
{
  "state": "TX",
  "keywords": "janitorial services",
  "set_aside": "hubzone",
  "max_results": 5,
  "notice_type": "solicitation"
}
```

**Example output**

```json
{
  "opportunities": [
    {
      "link": "https://sam.gov/workspace/contract/opp/68a0912bb79e4c43b3bb5085e50aff3b/view",
      "title": "Fort Hood Installation Custodial Services",
      "agency": "DEPT OF DEFENSE",
      "office": "W6QM MICC-FDO FT CAVAZOS",
      "industry": "Janitorial Services",
      "notice_id": "68a0912bb79e4c43b3bb5085e50aff3b",
      "set_aside": "HUBZone Set Aside",
      "naics_code": "561720",
      "notice_type": "Solicitation",
      "posted_date": "2026-09-25",
      "response_deadline": "2026-10-07T10:00:00-05:00",
      "solicitation_number": "W91151-26-R-A004",
      "place_of_performance": "Fort Hood, Texas, UNITED STATES"
    }
  ]
}
```

## Quick start

Call the API with a Fous API key (`FOUS_API_KEY`). To create one, turn on Developer mode in Fous Studio, then open Keys & connections → API keys (https://app.fous.com/keys).

```bash
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
: "${FOUS_API_KEY:?Set FOUS_API_KEY before running this example}"

curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 120 \
  -H "Authorization: Bearer $FOUS_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "api": "@sam-gov",
  "visibility": "public",
  "operation": "search_contract_opportunities",
  "version": 1,
  "input": {
    "state": "TX",
    "keywords": "janitorial services",
    "set_aside": "hubzone",
    "max_results": 5,
    "notice_type": "solicitation"
  },
  "response": {
    "format": "json"
  }
}'
```

```python
# Save as fous.py and run with python3 fous.py. No packages needed.
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
import json
import os
import urllib.error
import urllib.request

api_key = os.environ.get("FOUS_API_KEY")
if not api_key:
    raise RuntimeError("Set FOUS_API_KEY before running this example")

body = json.loads("{\n  \"api\": \"@sam-gov\",\n  \"visibility\": \"public\",\n  \"operation\": \"search_contract_opportunities\",\n  \"version\": 1,\n  \"input\": {\n    \"state\": \"TX\",\n    \"keywords\": \"janitorial services\",\n    \"set_aside\": \"hubzone\",\n    \"max_results\": 5,\n    \"notice_type\": \"solicitation\"\n  },\n  \"response\": {\n    \"format\": \"json\"\n  }\n}")
request = urllib.request.Request(
    "https://api.fous.com/v1/query",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urllib.request.urlopen(request, timeout=120) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8', errors='replace')}") from error
if result.get("success") is False:
    raise RuntimeError(result.get("error", {}).get("message", "Request failed"))
print(json.dumps(result["data"]["output"], indent=2))
```

```typescript
// Save as fous.mts and run with npx tsx fous.mts.
// First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
const apiKey = process.env.FOUS_API_KEY;
if (!apiKey) throw new Error("Set FOUS_API_KEY before running this example");

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(120_000),
  body: JSON.stringify({
  "api": "@sam-gov",
  "visibility": "public",
  "operation": "search_contract_opportunities",
  "version": 1,
  "input": {
    "state": "TX",
    "keywords": "janitorial services",
    "set_aside": "hubzone",
    "max_results": 5,
    "notice_type": "solicitation"
  },
  "response": {
    "format": "json"
  }
}),
});
type ApiResult = { success: boolean; data?: { output: unknown }; error?: { message: string } };
const result: ApiResult = await response.json();
if (!response.ok || result.success === false) {
  throw new Error(result.error?.message ?? `HTTP ${response.status}`);
}
if (!result.data) throw new Error("Missing API response data");
console.log(result.data.output);
```

Or describe the data in plain language: send `{"api":"@sam-gov","prompt":"Describe the data you need, with every detail"}` to the same URL. Fous fills in the input, runs the method that fits and returns only the fields you asked for; `data.route.calls[].request` is the exact call it made. Routing is free; the run costs the same.

## Use cases

- Find notices matching a service or product keyword
- Identify opportunities from a specific federal agency
- Track response deadlines and solicitation numbers
- Review notices by set-aside or industry
- Locate contract opportunities by place of performance

## FAQ

### Is Fous affiliated with SAM.gov?

No. Fous is not affiliated with SAM.gov. This workflow reads the public sam.gov website and returns its data.

### How much does it cost?

Each run costs 1 credit. With pay-as-you-go, a credit costs 1¢; monthly plans cost less per credit.

### Do I need a SAM.gov account?

No. You only need a Fous account.

### How current is the data?

Fous gets the data from sam.gov when you run it; repeating the same request within a day may return the saved result. Fous checks this workflow automatically; it last passed a check on Sep 29, 2026.

### Which federal notices match my keywords?

Search contract opportunities finds active federal contract notices matching the required keywords and any filters you provide.

### When is a notice response due?

Search contract opportunities returns the response deadline when it is published on the notice.

### Where will the work take place?

Search contract opportunities returns the place of performance when it is published on the notice.

## Related

- [Grants.gov API](https://fous.com/workflows/grants-gov.md): U.S. federal grant opportunities and application information.
- [USAspending API](https://fous.com/workflows/usaspending.md): USAspending provides official federal spending data and searchable awards from October 1, 2007 onward; figures and agency account reports may be revised or lag published award updates.
- [USAJOBS API](https://fous.com/workflows/usajobs.md): Federal government job listings and announcements.
- [Find a Tender API](https://fous.com/workflows/find-a-tender.md): UK government public procurement notices and tenders.
- [Tenders Electronic Daily API](https://fous.com/workflows/tenders-electronic-daily.md): Tenders Electronic Daily provides recently published EU procurement notices, open tenders with future deadlines, and newest-first contract awards; values and deadlines may be absent.
- [Federal Register API](https://fous.com/workflows/federal-register.md): Search United States federal rules, proposed rules, notices, and presidential documents.
- [FBI API](https://fous.com/workflows/fbi.md): Federal Bureau of Investigation wanted notices and public safety information.
- [Congress.gov API](https://fous.com/workflows/congress-gov.md): Congress.gov returns federal bills and resolutions matching topic, Congress, status, or chamber, and provides an individual bill’s status, summary, titles, actions, and related bills; summaries may be unavailable.
- [All Government workflows](https://fous.com/workflows/category/government)
