# Find a business

Look up a business's signed profile, search the directory by category, and check that an agent selling for a business is the one it lists.

Use this when your agent is about to buy from a business, or an agent says it sells for one. You look up the business's signed profile, read its rules and selling agents, and check that the agent and its key are the ones the profile lists before you accept an offer.

**Before you begin:** none of these calls needs a key. Fetch and cache the issuer's keys from `/.well-known/jwks.json` ([Verify tokens offline](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md)).

## 1. Look up the business

Pass the domain you found the business at. A business that hasn't verified a domain or published a profile answers `404 profile_not_published`, the same answer as an unknown domain.

**curl**

```bash
curl -s "$PROVENANCE_API/v1/public/businesses/lookup?origin=saltmarsh.example"
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const profile = await prov.authorize.discovery.lookup("saltmarsh.example");
```

**Python**

```python
import os
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
profile = prov.authorize.discovery.lookup("saltmarsh.example")
```

```json
{
  "object": "provenance_profile",
  "business": { "id": "biz_01JDSAMPLE0SALTMARSH0DATA00", "name": "Saltmarsh Data", "origins": ["https://agents.saltmarsh.example", "https://saltmarsh.example"] },
  "accepts": { "approvals": true, "network_mandates": true, "rails": ["acp", "ap2", "checkout", "x402"] },
  "rules": { "person_required_over": 1000, "currency": "USD" },
  "selling": [{ "agent_id": "agt_01JDSAMPLE0TIDEPOOL0SALES00", "name": "Tidepool Sales", "kids": ["kOJ8b2…"] }],
  "signature": "eyJhbGciOiJFUzI1NiIsInR5cCI6InByb3ZlbmFuY2UtcHJvZmlsZStqd3QifQ…"
}
```

The same profile can reach you inside a 402 (`info.profile` in the x402 v2 `com.provenanceauth.intent` extension), an ACP capability declaration, an AP2 merchant agent's metadata (maps to AP2 0.2) or a checkout challenge's `profile_url`. `x402ProfileOf(paymentRequired)` reads it from a 402.

## 2. Search by category

Results are ordered by name, never ranked or recommended. Each selling agent carries its record in two facts: orders and rating.

**curl**

```bash
curl -s "$PROVENANCE_API/v1/public/businesses/search?category=data&sells_to_agents=true"
```

**Node**

```ts
const { data } = await prov.authorize.discovery.search({ category: "data", sellsToAgents: true });
```

**Python**

```python
results = prov.authorize.discovery.search(category="data", sells_to_agents=True)
```

```json
{
  "object": "list",
  "data": [{
    "object": "directory_business",
    "id": "biz_01JDSAMPLE0SALTMARSH0DATA00",
    "name": "Saltmarsh Data",
    "selling": [{ "agent_id": "agt_01JDSAMPLE0TIDEPOOL0SALES00", "name": "Tidepool Sales", "record": { "orders": 0, "rating": null, "rating_count": 0, "line": "New · 0 orders" } }]
  }],
  "has_more": false,
  "next_cursor": null
}
```

## 3. Check the seller agent against the profile

An offer or a request names the agent that sends it and the key it signs with. `verifySellerAgent` checks the profile's signature against the issuer's keys, that the profile lists the domain you found the business at, and that it lists this agent with this key.

**Node**

```ts
import { fetchJwks, verifySellerAgent } from "@provenanceauth/sdk";

const jwks = await fetchJwks(process.env.PROVENANCE_API!);
const check = await verifySellerAgent(profile, offer.iss, offer.kid, { jwks, origin: "https://saltmarsh.example", apiBase: process.env.PROVENANCE_API });
if (!check.valid) throw new Error(`not Saltmarsh's agent: ${check.reason}`);
```

**Python**

```python
from provenanceauth import fetch_jwks, verify_seller_agent

jwks = fetch_jwks(os.environ["PROVENANCE_API"])
check = verify_seller_agent(profile, offer_iss, offer_kid, jwks=jwks, origin="https://saltmarsh.example")
assert check.valid, check.reason
```

**Go**

```go
r := provenanceverify.VerifySellerAgent(profile, offerIss, offerKid, jwks, "https://saltmarsh.example", 0)
if !r.Valid { return fmt.Errorf("not Saltmarsh's agent: %s", r.Reason) }
```

| `reason` | Meaning |
| --- | --- |
| `signature_invalid` | The profile isn't signed by the issuer's keys. |
| `profile_tampered` | The profile was changed after it was signed. |
| `profile_expired` | The signature is past its expiry. Fetch the profile again. |
| `origin_not_in_profile` | The profile belongs to another business: it doesn't list the domain you found the business at. |
| `agent_not_listed` | This agent doesn't sell for this business. |
| `key_not_listed` | The agent is listed, but this key isn't one of its active keys. |
| `key_revoked` | With `apiBase`, the online check says the key is revoked or expired. |

> **Note: Check before you accept**
>
> An agent on a lookalike domain can copy a business's name and its agent's name. Only the signed profile for the domain you meant ties the agent and its key to that business.

## 4. Ask from an MCP client

Provenance MCP has two tools that need no key: add `?toolsets=verify` to the server's address. `check_counterparty` takes a domain and returns whether the business has a verified profile, its rules and its responding agents. `find_counterparties` searches by category. See [tools that need no key](https://provenanceauth.com/docs/provenance-mcp/agent-tools.md#tools-that-need-no-key).

## Errors you might see

| Code | What to do |
| --- | --- |
| [`profile_not_published`](https://provenanceauth.com/docs/platform/errors.md#profile_not_published) | The domain has no published profile. Treat an agent that says it sells for it as unverified. |
| [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded) | Lookups are limited per address each minute. Cache profiles for 5 minutes. |
| `parameter_invalid` on `category` | Use lowercase letters, digits and underscores. |

## See also

- [Be findable by agents](https://provenanceauth.com/docs/authorize/guides/be-findable-by-agents.md)
- [The discovery profile](https://provenanceauth.com/docs/authorize/reference/discovery-profile.md)
- [Buy from agents](https://provenanceauth.com/docs/authorize/guides/buy-from-agents.md)
