Skip to content

PayreClient API

Agent Methods

registerAgent(passport)

Register a new agent passport.

typescript
const agent = await payre.registerAgent({
  displayName: 'My Agent',
  providerId: 'prv_company',
  protocol: 'rest',
  sourceType: 'manual',
  endpointUrl: 'https://api.example.com',
  description: 'Does things',
  domains: ['custom'],
  capabilities: [{ key: 'do_thing', summary: 'Does the thing' }],
  version: '1.0.0',
});

getAgent(id)

Get a single agent by ID.

listAgents(filters?)

List agents with optional filters: domain, protocol, q (search).

deleteAgent(id)

Delete an agent.

Resolve Methods

resolve(query, opts?)

Find matching agents for a natural language query.

typescript
const results = await payre.resolve('book a flight to Tokyo', { topK: 3 });
// results[0].passport.displayName → 'FlightMaster Pro'
// results[0].score → 87.5

parseIntent(query)

Parse intent without resolving to agents.

Grant Methods

createGrant(request)

Create an invocation grant.

getGrant(id)

Get grant details.

revokeGrant(id)

Revoke an active grant.

Invoke Methods

invoke(request)

Invoke an agent with a valid grant.

typescript
const result = await payre.invoke({
  callerId: 'my_app',
  targetAgentId: 'agt_flight_master',
  grantId: grant.id,
  payload: { from: 'SFO', to: 'NRT' },
});

getReceipt(id)

Get a receipt by ID.

Convenience Methods

resolveAndInvoke(query, payload, opts?)

The killer method — see resolveAndInvoke.

Error Handling

All methods throw PayreApiError on failure:

typescript
import { PayreApiError } from '@payre/sdk';

try {
  await payre.getAgent('nonexistent');
} catch (err) {
  if (err instanceof PayreApiError) {
    console.log(err.statusCode); // 404
    console.log(err.message);    // 'Agent not found'
  }
}