TypeScript Example
Esta página aún no está disponible en tu idioma.
TypeScript Example
Section titled “TypeScript Example”This guide demonstrates how to call AgentBureau endpoints using fetch and handle blockchain transactions using viem. All requests now require the Idempotency-Key and PAYMENT-AUTHORIZATION headers.
The Authorization Pattern
Section titled “The Authorization Pattern”Every priced request follows this pattern in TypeScript:
- Challenge:
POSTwithIdempotency-Key. - Payment: Send USDC to the
receiverfound inPAYMENT-REQUIRED. - Sign: Sign the
X-PAYMENT-INTENT-IDwith the wallet:AgentBureau Intent: {intent_id}. - Settle: Retry with
PAYMENT-SIGNATURE(hash) andPAYMENT-AUTHORIZATION(signature).
const API_URL = 'https://agentbureau-api.datafortress.cloud/v1/fax';const payload = { recipient_number: '+49123456789', content: 'Hello from TypeScript!',};
// Headers for the final retryconst headers = { 'Content-Type': 'application/json', 'Idempotency-Key': 'uuid-v4-key', 'PAYMENT-SIGNATURE': '0x-tx-hash', 'PAYMENT-AUTHORIZATION': '0x-signature'};Letter
Section titled “Letter”const API_URL = 'https://agentbureau-api.datafortress.cloud/v1/letters';const payload = { recipient_address: { name: "Finanzamt Berlin", street: "Musterstraße 1", zip: "10115", city: "Berlin", country: "Germany" }, content_pdf_url: "https://example.com/letter.pdf"};Invoice
Section titled “Invoice”const API_URL = 'https://agentbureau-api.datafortress.cloud/v1/invoices';const payload = { customer_details: { name: "Acme Corp", email: "billing@acme.com", address: "123 Business Way, London, UK" }, line_items: [{ description: "AI Consulting", quantity: 10, unit_price: 150.00 }]};GmbH Formation
Section titled “GmbH Formation”const API_URL = 'https://agentbureau-api.datafortress.cloud/v1/companies/formations';const payload = { company_name: "Autonomous Ventures GmbH", shareholders: [{ name: "Alice Agent", shares: 25000, address: "Digital Ether 0x123" }]};