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

# SDK Preview

> Preview the planned Jurat TypeScript SDK shape before the package is published.

The Jurat SDK is not published yet.

Jurat plans to publish the SDK after the API contract is finalized. The SDK should live in its own codebase and package, separate from the hosted app.

For current integrations, use the REST API directly and follow the [Signing](/signing) guide. The examples below show the expected SDK direction, not an installable package.

## 1. Create A Client

```ts theme={null}
import { JuratRecoveryClient } from "@jurat/recovery-sdk"; // planned package

const jurat = new JuratRecoveryClient({
  baseUrl: "https://api.jurat.io/api/v1",
});
```

## 2. Provide A Signer

The planned SDK should accept a minimal signer interface:

```ts theme={null}
type JuratSigner = {
  address: string;
  signMessage(message: string): Promise<string>;
};
```

Example:

```ts theme={null}
const signer = {
  address: walletAddress,
  signMessage: message => wallet.signMessage(message),
};
```

This shape works with ethers, viem, wagmi, Privy, embedded wallets, and custody providers.

## 3. Create A Recovery Case

```ts theme={null}
import {
  encodeErc20Transfer,
  signRecoveryIntent,
} from "@jurat/recovery-sdk"; // planned package

const intent = {
  rec: {
    lostAccount: "0xLostSmartAccount",
    recoveryAccount: signer.address,
    chainId: 8453,
    reasonForRecovery: "lost key",
    email: "user@example.com",
  },
  txs: [
    {
      dest: "0xTokenContract",
      value: "0",
      data: encodeErc20Transfer(signer.address, 1000000n),
    },
  ],
};

const duplicate = await jurat.recoveryCaseExists(intent);

if (!duplicate.caseExists) {
  const signedIntent = await signRecoveryIntent(signer, intent);
  const created = await jurat.createRecoveryCase(signedIntent);
  console.log(created.caseId, created.jrcHash);
}
```

## 4. Submit Court Metadata

```ts theme={null}
import { signCourtInfo } from "@jurat/recovery-sdk"; // planned package

const courtInfo = {
  title: null,
  fullCaseNumber: "1:26-cv-00001",
  courtId: "candc",
  docketNumber: 42,
};

const signedCourtInfo = await signCourtInfo(signer, courtInfo);
await jurat.submitCourtOrder(jrcHash, signedCourtInfo);
```

## 5. Load Case Status

```ts theme={null}
const detail = await jurat.getRecoveryCase(caseId);

console.log(detail.recovery?.status);
console.log(detail.recovery?.txHash);
```

## 6. Load An Estate Profile

```ts theme={null}
const profile = await jurat.getEstateProfile(signer.address);
```

## 7. Create A Privacy Code

```ts theme={null}
import { signPrivacyCode } from "@jurat/recovery-sdk"; // planned package

const privacyCode = await signPrivacyCode(signer, {
  juratWalletAddress: signer.address,
  name: "Estate plan",
  state: "California",
});

await jurat.createPrivacyCode(signer.address, privacyCode);
```

## Error Handling

Future SDK methods should throw `Error` when the API returns a non-2xx response.

```ts theme={null}
try {
  await jurat.createRecoveryCase(signedIntent);
} catch (error) {
  console.error(error);
}
```

Backend errors include a stable code and request ID when raised through the structured error handler. Log the `requestId` when asking Jurat support to investigate an API failure.
