---
agent:
  instructions: "Use this search API to find Trusteed documentation (pages, blog posts, FAQ, error codes, the agent checkout guide and MCP tools) with keywords, instead of crawling individual pages. Results are returned in Markdown. It does not search store catalogues: for products use POST /api/v1/search."
  endpoint: "https://trusteed.xyz/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---
Source: https://trusteed.xyz/en/for-agents/examples

[![](/sol46/shield.svg)**Trusteed** Control and evidence for delegated operations](https://trusteed.xyz/en)

[ES](https://trusteed.xyz/es/for-agents/examples?setlang=es)[EN](https://trusteed.xyz/en/for-agents/examples?setlang=en)

[Log in](https://trusteed.xyz/en/login)[Audit your store for free↗](https://trusteed.xyz/en/audit)

# Code Examples

Copy and paste these examples to get started immediately

cURL Search Products

```
curl -X POST https://trusteed.xyz/demo-store/mcp/discovery \
  -H "Content-Type: application/json" \
  -H "X-Agent-Api-Key: YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "search_products",
      "arguments": {
        "query": "laptop",
        "limit": 10
      }
    }
  }'
```

Python Create Cart

```
import requests

response = requests.post(
  "https://trusteed.xyz/demo-store/mcp/checkout",
  headers={
    "X-Agent-Api-Key": "YOUR_SANDBOX_KEY",
    "Content-Type": "application/json"
  },
  json={
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "create_cart",
      "arguments": {
        "items": [{"product_id": "prod-017", "quantity": 1}]
      }
    }
  }
)

cart_id = response.json()["result"]["structuredContent"]["cart_id"]
print(f"Cart created: {cart_id}")
```

TypeScript Get Shipping Rates

```
const response = await fetch(
  "https://trusteed.xyz/demo-store/mcp/checkout",
  {
    method: "POST",
    headers: {
      "X-Agent-Api-Key": "YOUR_SANDBOX_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: 1,
      method: "tools/call",
      params: {
        name: "get_shipping_rates",
        arguments: {
          cart_id: cartId,
          shipping_address: {
            address1: "123 Main St",
            city: "San Francisco",
            province_code: "CA",
            country_code: "US",
            zip: "94105"
          }
        }
      }
    })
  }
);

const { result } = await response.json();
process.stdout.write(JSON.stringify(result.structuredContent));
```

cURL Select Shipping Option

```
curl -X POST https://trusteed.xyz/demo-store/mcp/checkout \
  -H "X-Agent-Api-Key: YOUR_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "select_shipping_option",
      "arguments": {
        "cart_id": "<cart_id from create_cart>",
        "shipping_handle": "standard"
      }
    }
  }'
```

Python Apply Discount

```
def apply_discount(cart_id: str, code: str) -> dict:
    """Apply discount code to cart."""
    response = requests.post(
        "https://trusteed.xyz/demo-store/mcp/checkout",
        headers={
            "X-Agent-Api-Key": "YOUR_SANDBOX_KEY",
            "Content-Type": "application/json"
        },
        json={
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
                "name": "apply_discount",
                "arguments": {
                    "cart_id": cart_id,
                    "discount_code": code
                }
            }
        }
    )
    return response.json()["result"]

result = apply_discount(cart_id, "TEST123")
print(result)
```

TypeScript Complete Checkout

```
async function completeCheckout(
  checkoutSessionId: string, // from preview_checkout
  idempotencyKey: string, // one per purchase attempt; reuse it on retry
  buyer: { name: string; email: string; phone: string }
) {
  const response = await fetch(
    "https://trusteed.xyz/demo-store/mcp/checkout",
    {
      method: "POST",
      headers: {
        "X-Agent-Api-Key": "YOUR_SANDBOX_KEY",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        jsonrpc: "2.0",
        id: 1,
        method: "tools/call",
        params: {
          name: "complete_checkout",
          arguments: {
            checkout_session_id: checkoutSessionId,
            idempotency_key: idempotencyKey,
            payment_method: "MOCK",
            buyer
          }
        }
      })
    }
  );

  const { result, error } = await response.json();
  // A missing key arrives as error.data.code === "no_credentials" (HTTP 200 on demo-store).
  if (error) throw new Error(error.data?.code ?? error.message);
  // COMPLETED → order_id. PENDING_EXTERNAL_CONFIRMATION → send the buyer to
  // approval_url / payment_url, then call again with the same two ids.
  return result.structuredContent;
}
```

## Tools Quick Reference

| Tool | Description | Auth Required |
| --- | --- | --- |
| search\_products | Search products with filters | Yes |
| get\_product\_details | Get full product details | Yes |
| create\_cart | Create shopping cart | Yes |
| get\_shipping\_rates | Get shipping rates | Yes |
| select\_shipping\_option | Select shipping option | Yes |
| apply\_discount | Apply discount code | Yes |
| preview\_checkout | Preview checkout | Yes |
| complete\_checkout | Complete payment | Yes |

## SDK Examples

Connect directly from your agent framework

OpenAI Agents SDK pip install openai-agents

```
# pip install openai-agents
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(
    name="trusteed",
    params={"url": "https://trusteed.xyz/{storeSlug}/mcp/discovery",
            "headers": {"X-Agent-Api-Key": "agnt_xxx"}}
) as mcp:
    agent = Agent(instructions="Verify the merchant's trust level before checkout.")
    result = await Runner.run_async(agent, "Find laptops under $1500")
```

Claude Agent SDK npm install @anthropic-ai/claude-agent-sdk

```
// npm install @anthropic-ai/claude-agent-sdk
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const msg of query({
  prompt: "Search products, verify the merchant's trust level, create cart",
  options: {
    mcpServers: { trusteed: { type: "http",
      url: "https://trusteed.xyz/{storeSlug}/mcp/discovery",
      headers: { "X-Agent-Api-Key": process.env.TRUSTEED_KEY } } },
    allowedTools: ["mcp__trusteed__search_products",
                   "mcp__trusteed__get_merchant_profile",
                   "mcp__trusteed__create_cart"],
  },
})) { if (msg.type === "result") process.stdout.write(msg.result); }
```

Vercel AI SDK npm install ai @ai-sdk/openai

```
// npm install ai @ai-sdk/openai
import { experimental_createMCPClient as createMCPClient } from "ai";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const mcp = await createMCPClient({ transport: { type: "http",
  url: "https://trusteed.xyz/{storeSlug}/mcp/discovery",
  headers: { "X-Agent-Api-Key": process.env.TRUSTEED_KEY } } });

const { text } = await generateText({ model: openai("gpt-4o"),
  tools: await mcp.tools(), maxSteps: 5,
  prompt: "Find laptops, verify the merchant's trust level, create cart" });
await mcp.close();
```

Full quickstart [/for-agents/sdk-quickstarts →](https://trusteed.xyz/en/for-agents/sdk-quickstarts)

## MCP 3-Bucket Endpoints

Each store exposes three specialized endpoints (Discovery / Customer / Checkout). Pick the bucket that matches your operation scope.

Deprecation notice: legacy endpoint

The monolithic `/{storeSlug}/mcp` endpoint is deprecated and retired: it returns 410 with `endpoint_sunset` and a successor map in the response body (see also the `Sunset` and `Deprecation` response headers). Migrate to the per-bucket endpoints.

Discovery: `POST /{storeSlug}/mcp/discovery` anonymous · cacheable · 20 tools

```
# tools/list (no auth required)
curl -X POST https://trusteed.xyz/demo-store/mcp/discovery \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# tools/call search_products
curl -X POST https://trusteed.xyz/demo-store/mcp/discovery \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{
    "jsonrpc":"2.0","id":2,"method":"tools/call",
    "params":{
      "name":"search_products",
      "arguments":{"query":"laptop","limit":5}
    }
  }'
```

Customer: `POST /{storeSlug}/mcp/customer` OAuth 2.1 · resource=customer-mcp · 9 tools

```
# tools/call onx_get_orders (Bearer OAuth + RFC 8707 resource indicator)
curl -X POST https://trusteed.xyz/demo-store/mcp/customer \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -H "Authorization: Bearer $CUSTOMER_OAUTH_TOKEN" \
  -d '{
    "jsonrpc":"2.0","id":3,"method":"tools/call",
    "params":{
      "name":"onx_get_orders",
      "arguments":{"limit":10}
    }
  }'

# Note: token MUST be issued with resource indicator
#   resource=https://trusteed.xyz/{storeSlug}/mcp/customer
# (RFC 8707). Tokens for other resources will 401.
```

Checkout: `POST /{storeSlug}/mcp/checkout` AgenticTrust · Idempotency-Key · mandate · 27 tools

```
# tools/call complete_checkout
# Needs a credential. The payment mandate is the one the platform issues after
# the buyer approves approval_url (held by the platform, or sent in
# X-Payment-Mandate / payment_mandate); a cap you declare yourself is optional.
# On demo-store the credential is a sandbox key.
curl -X POST https://trusteed.xyz/demo-store/mcp/checkout \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -H "X-Agent-Api-Key: $SANDBOX_KEY" \
  -H "X-Payment-Mandate: $PAYMENT_MANDATE" \
  -d '{
    "jsonrpc":"2.0","id":4,"method":"tools/call",
    "params":{
      "name":"complete_checkout",
      "arguments":{
        "checkout_session_id":"<checkout_session_id from preview_checkout>",
        "idempotency_key":"550e8400-e29b-41d4-a716-446655440000",
        "payment_method":"MOCK",
        "buyer":{
          "name":"Ada Lovelace",
          "email":"ada@example.com",
          "phone":"+34600000000"
        }
      }
    }
  }'

# The result's status tells you what happened: COMPLETED (order_id set;
# simulated on demo-store) or PENDING_EXTERNAL_CONFIRMATION (send the buyer to
# approval_url / payment_url, then call again with the same
# checkout_session_id and idempotency_key).
```

When to use each bucket? [See the matrix in the quickstart →](https://trusteed.xyz/en/for-agents/quickstart)
