> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pesarc.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents & AI

> Let an AI assistant or automated workflow move money through Pesarc in plain language.

Pesarc exposes the same agent that powers the in-app chat and WhatsApp bridge as
an API, so your own product, copilot or automation can move money in natural
language.

## One turn

Send a plain-language message; the agent understands it and acts — create a
market, pay a bill, or submit and settle a cross-border transfer peer-to-peer in
local currency — and replies with what it did.

```ts theme={null}
const res = await fetch("https://pesarc.xyz/api/agent/settle", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PESARC_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ message: "Send ₦50,000 to Ama in Accra" }),
});
const result = await res.json();
// { reply: "...", ...action details }
```

See [`POST /agent/settle`](/api-reference/agent-settle) for the full contract.

## Use it as a tool

If you're building on an LLM framework, wrap the endpoint as a single tool your
model can call. Keep the tool description tight and let Pesarc's agent do the
money reasoning:

```ts theme={null}
const pesarcTool = {
  name: "pesarc_money",
  description:
    "Move money or answer money questions for the user via Pesarc. " +
    "Pass the user's request verbatim, e.g. 'pay my electricity bill'.",
  inputSchema: {
    type: "object",
    properties: { message: { type: "string" } },
    required: ["message"],
  },
  async execute({ message }: { message: string }) {
    const res = await fetch("https://pesarc.xyz/api/agent/settle", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.PESARC_SECRET_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ message }),
    });
    return res.json();
  },
};
```

## Safety

<Warning>
  Anything that moves money should be confirmed by a human. When you build the
  agent into your own product, surface Pesarc's described action to the user and
  get an explicit confirmation before treating money movement as authorised. Never
  expose your secret key to the model or the client — keep the call server-side.
</Warning>

<Note>
  The agent is rate-limited. Design for retries with backoff and handle a
  non-`200` status by showing the agent's `reply` to the user rather than failing
  silently.
</Note>
