# Use Credentials with the SDK

> Author Credential Provider lifecycles and consume protected credentials through governed Resources without reading secret material.

There are two SDK boundaries: provider code manages lifecycle; Agent code consumes only a governed Resource.

## Provider code {#provider-code}

```ts
import { credentialProvider } from "@constal/sdk";

export default credentialProvider({
  id: "example-token", version: "1.0.0", displayName: "Example token",
  description: "Mints a short-lived token.", credentialSlots: ["bootstrap-token"],
  configSchema: { type: "object", additionalProperties: false },
  credentialConfigSchema: { type: "object", additionalProperties: false },
  rotation: { mode: "manual", intervalMs: null, overlapMs: 0, maxAgeMs: null, refreshBeforeMs: 0 },
  egress: { rules: [] }, mintRecovery: { kind: "outcome-unknown" },
  async mint(_request, context) {
    const bootstrap = await context.secret("bootstrap-token");
    return { material: bootstrap.value };
  },
});
```

## Agent code {#agent-code}

```ts
const profile = await ctx.invoke(
  ctx.resources.github!, "user.get", {}, { timeoutMs: 30_000 },
);
```

`Ctx` has no secret method. The protected integration declares the Credential slot it consumes, and Constal supplies the active version only after binding and Policy resolution. Scoped bindings can select tenant-, customer-, or principal-specific authority before Run admission. Provider-private state and consumer material remain separate; public APIs expose fingerprints and lifecycle state, never bytes. Continue with [Build a Credential Provider](/docs/credentials/providers/build.md) and [Use a credential from an agent](/docs/credentials/use-from-agent.md).
