# INFRA Connect

INFRA Connect lets you request user consent directly via API — no OAuth redirect required. The user receives an in-app notification to approve or deny.

## How it works

1. **Request Consent** — POST to /connect/request with the user's INFRA ID and the scopes you need.
2. **User Gets Notified** — The user receives a push notification in the INFRA mobile app with your request details.
3. **User Approves or Denies** — User reviews and approves or denies the request in-app.
4. **Poll for Result** — Poll GET /connect/result/:requestId or receive a consent.granted webhook.

## Request consent

```javascript
const response = await fetch(
  'https://api.infraidentity.com/api/v1/connect/request',
  {
    method: 'POST',
    headers: {
      'Authorization': `Basic ${btoa(`${clientId}:${clientSecret}`)}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      infra_user_id: 'usr_01HXYZ...',
      scopes: ['profile:basic', 'kyc:status'],
      callback_url: 'https://yourapp.com/webhooks/infra',
    }),
  }
);

// Response
{
  "request_id": "req_01HXYZ...",
  "status": "pending",
  "expires_in": 300
}
```

## Poll for the result

```javascript
const result = await fetch(
  `https://api.infraidentity.com/api/v1/connect/result/${requestId}`,
  {
    headers: {
      'Authorization': `Basic ${btoa(`${clientId}:${clientSecret}`)}`,
    },
  }
);

// Response when approved
{
  "request_id": "req_01HXYZ...",
  "status": "approved",
  "user_id": "usr_01HXYZ...",
  "granted_scopes": ["profile:basic", "kyc:status"],
  "access_token": "eyJ..."
}
```

---

Source: https://docs.infraidentity.com/infra-connect/ · Full docs: https://docs.infraidentity.com/llms-full.txt
