|
| 1 | +# AgentID TypeScript Client |
| 2 | + |
| 3 | +Small helper client for calling an AgentID gateway from a SaaS app or agent |
| 4 | +runtime. |
| 5 | + |
| 6 | +```ts |
| 7 | +import { AgentIdClient } from "@agentid/client"; |
| 8 | + |
| 9 | +const agentid = new AgentIdClient({ |
| 10 | + baseUrl: "https://agentid-gateway.example.com", |
| 11 | + token: async () => getAccessTokenFromYourIdP(), |
| 12 | +}); |
| 13 | + |
| 14 | +await agentid.assertAllowed("tenant-a", { |
| 15 | + agent_id: "refund-agent", |
| 16 | + tool: "zendesk.search_tickets", |
| 17 | + action: "read", |
| 18 | + data_from: "zendesk", |
| 19 | + data_to: "agent_context", |
| 20 | +}); |
| 21 | + |
| 22 | +const grant = await agentid.requestJitGrant("tenant-a", { |
| 23 | + tool: "stripe.create_refund", |
| 24 | + action: "write", |
| 25 | + resource: "refund/case-1042", |
| 26 | + approval_id: "approval-123", |
| 27 | + user_id: "support-rep-17", |
| 28 | +}); |
| 29 | + |
| 30 | +await agentid.assertAllowed("tenant-a", { |
| 31 | + agent_id: "refund-agent", |
| 32 | + tool: "stripe.create_refund", |
| 33 | + action: "write", |
| 34 | + resource: "refund/case-1042", |
| 35 | + approved: true, |
| 36 | + jit_grant_id: grant.jit_grant_id, |
| 37 | +}); |
| 38 | +``` |
0 commit comments