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

# Signup quickstart

> Gate the free credits or first API key of a new account on one NoResponse call. Works with Clerk, WorkOS, Auth0 or your own login.

Call NoResponse first from the backend code that gives a new account something of value to an attacker. That is its free credits or its first API key. This page builds that gate in TypeScript, Python or Go. It works for an app that uses Clerk, WorkOS or Auth0 for login, or that has its own login.

The gate does these things in order:

1. Your backend verifies the session of the new account, and maps the verified claims to `auth_context`.
2. It creates the API key of the account, inactive.
3. It calls `POST /v1/assessments` with flow `account_creation` and the SHA-256 of the key.
4. It applies the decision: `block` refuses, `allow` grants, `step_up` asks for a second factor and `review` holds the account.

### 1. Create a workspace

Create your workspace with your email address. One call creates it and immediately answers its test key. Thus you or your agent can start before anyone opens a mailbox.

```bash title="Create a workspace" highlight={3} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl -sS -X POST https://api.noresponse.org/v1/onboarding \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com"}'
```

```json title="Response" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "workspace_id": "tnt_01JA2Z8K6Q4V7W9XBCDEFGHJKN",
  "test_key": "nrk_test_...",
  "live_key": {
    "status": "verification_sent",
    "message": "Verify your email to get a live key: open the link we sent, or post its token to POST /v1/onboarding/verify. It works once within 24 hours."
  }
}
```

To give the workspace a name, such as the name of your company, add `workspace_name` to the body: `{"email":"you@example.com","workspace_name":"Acme"}`. Without it, the workspace has no name until you give it one in the [console](https://app.noresponse.org).

The test key starts with `nrk_test_`. NoResponse shows it once, so store it now. It carries the `assess`, `history`, `delete`, `webhooks`, `integrations` and `groups` scopes. `assess` covers every call on this page: it creates the assessment and polls it with `wait`.

> [!NOTE]
>
> A test key calls the same API as a live key, but a deterministic simulator answers it. NoResponse looks up no source and charges nothing. Magic emails such as `step_up@test.noresponse.org` and `block@test.noresponse.org` give each decision when you want it. [Test your integration](https://docs.noresponse.org/testing.md) lists every magic identifier.

The data that you create with a test key stays in your test environment, separate from live data. You build this full page on the test key. In the last step you change to a live key (`nrk_live_`). [Test and live environments](https://docs.noresponse.org/authentication.md#test-and-live-environments) explains the two environments.

The live key comes from the email that we send to your address. Open its link, or post the token from it:

```bash title="Claim the live key" highlight={3} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl -sS -X POST https://api.noresponse.org/v1/onboarding/verify \
  -H "Content-Type: application/json" \
  -d '{"token":"nrsu_..."}'
```

The answer has `status` `active` and your `live_key`. NoResponse shows the live key once. Some workspace creations answer `status` `held` instead. We then examine the workspace, and email you a link that claims the live key after we approve it. Your test key works during this time.

If our own assessment blocks the creation, it answers 403 `workspace_refused` and gives no key. While your verification link waits unopened, a second call for the same address answers 409 `signup_pending` and makes nothing. The link works for 24 hours. One address can create a workspace 3 times an hour.

> [!TIP]
>
> If we invited your team to the [console](https://app.noresponse.org), you can create the workspace there:
>
> 1. Open the invitation email and create your user with your work address.
> 2. Enter your company name. The console makes the same call and shows the test key once.
> 3. Create more keys on **API keys**. A live key is in the live environment.

### 2. Set your keys

Put your keys in the environment of your backend, next to the keys of your auth provider. Keep all of them out of browser and mobile code.

> [tab] Clerk
>
> ```bash title="Environment" highlight={1-2} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> export NORESPONSE_API_KEY="nrk_..."
> export CLERK_SECRET_KEY="sk_test_..."    # Clerk Dashboard, API keys
> ```

> [tab] WorkOS
>
> ```bash title="Environment" highlight={1-3} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> export NORESPONSE_API_KEY="nrk_..."
> export WORKOS_API_KEY="sk_..."           # WorkOS Dashboard, API keys
> export WORKOS_CLIENT_ID="client_..."     # WorkOS Dashboard, API keys
> ```

> [tab] Auth0
>
> ```bash title="Environment" highlight={1-5} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> export NORESPONSE_API_KEY="nrk_..."
> export AUTH0_DOMAIN="your-tenant.us.auth0.com"
> export AUTH0_CLIENT_ID="..."             # the application your users sign in to
> export AUTH0_M2M_CLIENT_ID="..."         # a Machine to Machine application
> export AUTH0_M2M_CLIENT_SECRET="..."     # authorized for the Management API with read:users
> ```

> [tab] Your own login
>
> ```bash title="Environment" highlight={1} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> export NORESPONSE_API_KEY="nrk_..."
> ```

The NoResponse SDKs read `NORESPONSE_API_KEY` and call `https://api.noresponse.org`. You set nothing more for NoResponse.

> [!TIP]
>
> To receive late answers by webhook later, ask for a second key with the `webhooks` scope. Keep it separate from this key. [Webhooks](https://docs.noresponse.org/guides/webhooks.md#register-an-endpoint) shows how to use it.

### 3. Install the SDKs

Install the NoResponse SDK and the SDK of your auth provider. WorkOS and Auth0 sessions are JSON Web Tokens, so those tabs add a JWT library to verify them. With your own login, you install only the NoResponse SDK.

> [tab] Clerk
>
> ```bash title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> npm install @noresponse/node @clerk/backend
> ```
>
> ```bash title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> pip install noresponse clerk-backend-api
> ```
>
> ```bash title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> go get github.com/noresponsehq/go/v14 github.com/clerk/clerk-sdk-go/v2
> ```

> [tab] WorkOS
>
> ```bash title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> npm install @noresponse/node @workos-inc/node jose
> ```
>
> ```bash title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> pip install noresponse workos "pyjwt[crypto]"
> ```
>
> ```bash title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> go get github.com/noresponsehq/go/v14 github.com/workos/workos-go/v10 github.com/golang-jwt/jwt/v5 github.com/MicahParks/keyfunc/v3
> ```

> [tab] Auth0
>
> ```bash title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> npm install @noresponse/node auth0 jose
> ```
>
> ```bash title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> pip install noresponse auth0-python "pyjwt[crypto]"
> ```
>
> ```bash title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> go get github.com/noresponsehq/go/v14 github.com/auth0/go-auth0/v3 github.com/golang-jwt/jwt/v5 github.com/MicahParks/keyfunc/v3
> ```

> [tab] Your own login
>
> ```bash title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> npm install @noresponse/node
> ```
>
> ```bash title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> pip install noresponse
> ```
>
> ```bash title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> go get github.com/noresponsehq/go/v14
> ```

The NoResponse SDKs need Node.js 20, Python 3.10 or Go 1.24 or later. Of the provider packages, `@workos-inc/node` needs Node.js 22.11, the Go JWT module needs Go 1.25, and the Go Auth0 module needs Go 1.26.

### 4. Verify the session and map it

Your backend verifies the session with the SDK of your auth provider. Then it reads the user record for the facts that the token does not hold. The NoResponse adapter changes the verified claims and those facts into `auth_context`. NoResponse refuses raw tokens, so only verified claims leave your backend.

The account id is the user id from your auth provider, sent without change. The gate looks up the email address of the account. Thus `verifyNewAccount` refuses a user without one.

> [tab] Clerk
>
> Use the Clerk session token that your frontend sends. Clerk's `getToken()` returns it. Send it in the `Authorization: Bearer` header.
>
> Replace `https://app.example.com` with the origin of your frontend. Clerk compares it with the `azp` claim of the token.
>
> ```ts title="TypeScript" highlight={11} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import { createClerkClient, verifyToken } from "@clerk/backend";
> import { fromClerk, type AuthContext } from "@noresponse/node";
>
> const clerk = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY });
>
> export type VerifiedAccount = { accountId: string; email: string; authContext: AuthContext };
>
> export async function verifyNewAccount(sessionToken: string): Promise<VerifiedAccount> {
>   const claims = await verifyToken(sessionToken, {
>     secretKey: process.env.CLERK_SECRET_KEY,
>     authorizedParties: ["https://app.example.com"],
>   });
>   const user = await clerk.users.getUser(claims.sub);
>   const email = user.primaryEmailAddress;
>   if (!email) throw new Error(`Clerk user ${user.id} has no primary email address`);
>
>   return {
>     accountId: user.id,
>     email: email.emailAddress,
>     authContext: fromClerk(claims, {
>       accountCreatedAt: new Date(user.createdAt).toISOString(),
>       emailVerified: email.verification?.status === "verified",
>     }),
>   };
> }
> ```
>
> ```python title="Python" highlight={23} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import os
> from dataclasses import dataclass
> from datetime import datetime, timezone
>
> from clerk_backend_api import Clerk
> from clerk_backend_api.security import verify_token
> from clerk_backend_api.security.types import VerifyTokenOptions
> from noresponse import AuthContext, from_clerk
>
> clerk = Clerk(bearer_auth=os.environ["CLERK_SECRET_KEY"])
>
>
> @dataclass
> class VerifiedAccount:
>     account_id: str
>     email: str
>     auth_context: AuthContext
>
>
> def verify_new_account(session_token: str) -> VerifiedAccount:
>     claims = verify_token(
>         session_token,
>         VerifyTokenOptions(secret_key=os.environ["CLERK_SECRET_KEY"], authorized_parties=["https://app.example.com"]),
>     )
>     user = clerk.users.get(user_id=claims["sub"])
>     email = next((e for e in user.email_addresses or [] if e.id == user.primary_email_address_id), None)
>     if email is None:
>         raise ValueError(f"Clerk user {user.id} has no primary email address")
>     created = datetime.fromtimestamp(user.created_at / 1000, tz=timezone.utc)
>
>     return VerifiedAccount(
>         account_id=user.id,
>         email=email.email_address,
>         auth_context=from_clerk(claims, {
>             "account_created_at": created.strftime("%Y-%m-%dT%H:%M:%SZ"),
>             "email_verified": email.verification is not None and email.verification.status == "verified",
>         }),
>     )
> ```
>
> ```go title="Go" highlight={30} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> package main
>
> import (
> 	"context"
> 	"fmt"
> 	"os"
> 	"time"
>
> 	"github.com/clerk/clerk-sdk-go/v2"
> 	"github.com/clerk/clerk-sdk-go/v2/jwt"
> 	"github.com/clerk/clerk-sdk-go/v2/user"
> 	noresponse "github.com/noresponsehq/go/v14"
> 	"github.com/noresponsehq/go/v14/models/components"
> )
>
> type verifiedAccount struct {
> 	AccountID   string
> 	Email       string
> 	AuthContext *components.AuthContext
> }
>
> func init() {
> 	clerk.SetKey(os.Getenv("CLERK_SECRET_KEY"))
> }
>
> func verifyNewAccount(ctx context.Context, sessionToken string) (verifiedAccount, error) {
> 	claims := map[string]any{} // every verified claim, for the adapter
> 	session, err := jwt.Verify(ctx, &jwt.VerifyParams{
> 		Token:                   sessionToken,
> 		AuthorizedPartyHandler:  func(azp string) bool { return azp == "https://app.example.com" },
> 		CustomClaimsConstructor: func(context.Context) any { return &claims },
> 	})
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	usr, err := user.Get(ctx, session.Subject)
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	var email *clerk.EmailAddress
> 	for _, address := range usr.EmailAddresses {
> 		if usr.PrimaryEmailAddressID != nil && address.ID == *usr.PrimaryEmailAddressID {
> 			email = address
> 		}
> 	}
> 	if email == nil {
> 		return verifiedAccount{}, fmt.Errorf("clerk user %s has no primary email address", usr.ID)
> 	}
>
> 	authContext, err := noresponse.FromClerkClaims(claims, map[string]any{
> 		"account_created_at": time.UnixMilli(usr.CreatedAt).UTC().Format(time.RFC3339),
> 		"email_verified":     email.Verification != nil && email.Verification.Status == "verified",
> 	})
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	return verifiedAccount{AccountID: usr.ID, Email: email.EmailAddress, AuthContext: authContext}, nil
> }
> ```

> [tab] WorkOS
>
> Use the AuthKit access token. `authenticateWithCode` returns it in the callback of your login, and after that your session holds it. WorkOS signs the token with keys that it publishes for your client id. Thus a token that verifies against that key set is a token that WorkOS issued to your app.
>
> ```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import { createRemoteJWKSet, jwtVerify } from "jose";
> import { WorkOS } from "@workos-inc/node";
> import { fromWorkOS, type AuthContext } from "@noresponse/node";
>
> const workos = new WorkOS(process.env.WORKOS_API_KEY);
> const jwks = createRemoteJWKSet(new URL(workos.userManagement.getJwksUrl(process.env.WORKOS_CLIENT_ID ?? "")));
>
> export type VerifiedAccount = { accountId: string; email: string; authContext: AuthContext };
>
> export async function verifyNewAccount(accessToken: string): Promise<VerifiedAccount> {
>   const { payload: claims } = await jwtVerify(accessToken, jwks);
>   if (!claims.sub) throw new Error("WorkOS access token has no sub claim");
>   const user = await workos.userManagement.getUser(claims.sub);
>
>   return {
>     accountId: user.id,
>     email: user.email,
>     authContext: fromWorkOS(claims, {
>       accountCreatedAt: user.createdAt.toISOString(),
>       emailVerified: user.emailVerified,
>     }),
>   };
> }
> ```
>
> ```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import os
> from dataclasses import dataclass
> from datetime import timezone
>
> import jwt
> from workos import WorkOSClient
> from noresponse import AuthContext, from_workos
>
> workos = WorkOSClient(api_key=os.environ["WORKOS_API_KEY"], client_id=os.environ["WORKOS_CLIENT_ID"])
> jwks = jwt.PyJWKClient(workos.user_management.get_jwks_url())
>
>
> @dataclass
> class VerifiedAccount:
>     account_id: str
>     email: str
>     auth_context: AuthContext
>
>
> def verify_new_account(access_token: str) -> VerifiedAccount:
>     signing_key = jwks.get_signing_key_from_jwt(access_token).key
>     claims = jwt.decode(access_token, signing_key, algorithms=["RS256"], options={"verify_aud": False, "require": ["exp", "sub"]})
>     user = workos.user_management.get_user(claims["sub"])
>
>     return VerifiedAccount(
>         account_id=user.id,
>         email=user.email,
>         auth_context=from_workos(claims, {
>             "account_created_at": user.created_at.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
>             "email_verified": user.email_verified,
>         }),
>     )
> ```
>
> ```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> package main
>
> import (
> 	"context"
> 	"log"
> 	"os"
>
> 	"github.com/MicahParks/keyfunc/v3"
> 	"github.com/golang-jwt/jwt/v5"
> 	noresponse "github.com/noresponsehq/go/v14"
> 	"github.com/noresponsehq/go/v14/models/components"
> 	"github.com/workos/workos-go/v10"
> )
>
> type verifiedAccount struct {
> 	AccountID   string
> 	Email       string
> 	AuthContext *components.AuthContext
> }
>
> var (
> 	wos  = workos.NewClient(os.Getenv("WORKOS_API_KEY"), workos.WithClientID(os.Getenv("WORKOS_CLIENT_ID")))
> 	jwks keyfunc.Keyfunc
> )
>
> func init() {
> 	var err error
> 	if jwks, err = keyfunc.NewDefault([]string{wos.JWKSURLFromClient()}); err != nil {
> 		log.Fatal(err)
> 	}
> }
>
> func verifyNewAccount(ctx context.Context, accessToken string) (verifiedAccount, error) {
> 	token, err := jwt.Parse(accessToken, jwks.Keyfunc, jwt.WithValidMethods([]string{"RS256"}), jwt.WithExpirationRequired())
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	claims := token.Claims.(jwt.MapClaims)
> 	subject, err := claims.GetSubject()
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	usr, err := wos.UserManagement().Get(ctx, subject)
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
>
> 	authContext, err := noresponse.FromWorkOSClaims(claims, map[string]any{
> 		"account_created_at": usr.CreatedAt,
> 		"email_verified":     usr.EmailVerified,
> 	})
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	return verifiedAccount{AccountID: usr.ID, Email: usr.Email, AuthContext: authContext}, nil
> }
> ```

> [tab] Auth0
>
> Use the ID token from the callback of your login. Its issuer is your Auth0 domain and its audience is `AUTH0_CLIENT_ID`. The account id is the Auth0 user id, such as `auth0|64abc0de1234567890abcdef`. NoResponse accepts the vertical bar.
>
> ```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import { createRemoteJWKSet, jwtVerify } from "jose";
> import { ManagementClient } from "auth0";
> import { fromAuth0, type AuthContext } from "@noresponse/node";
>
> const domain = process.env.AUTH0_DOMAIN;
> const audience = process.env.AUTH0_CLIENT_ID;
> if (!domain || !audience) throw new Error("AUTH0_DOMAIN and AUTH0_CLIENT_ID are required");
> const issuer = `https://${domain}/`;
> const jwks = createRemoteJWKSet(new URL(`${issuer}.well-known/jwks.json`));
> const management = new ManagementClient({
>   domain,
>   clientId: process.env.AUTH0_M2M_CLIENT_ID ?? "",
>   clientSecret: process.env.AUTH0_M2M_CLIENT_SECRET ?? "",
> });
>
> export type VerifiedAccount = { accountId: string; email: string; authContext: AuthContext };
>
> export async function verifyNewAccount(idToken: string): Promise<VerifiedAccount> {
>   const { payload: claims } = await jwtVerify(idToken, jwks, { issuer, audience });
>   if (!claims.sub) throw new Error("Auth0 ID token has no sub claim");
>   const user = await management.users.get(claims.sub);
>   if (!user.email) throw new Error(`Auth0 user ${claims.sub} has no email address`);
>
>   return {
>     accountId: claims.sub,
>     email: user.email,
>     authContext: fromAuth0(claims, {
>       accountCreatedAt: user.created_at,
>     }),
>   };
> }
> ```
>
> ```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import os
> from dataclasses import dataclass
> from datetime import timezone
>
> import jwt
> from auth0.management import ManagementClient
> from noresponse import AuthContext, from_auth0
>
> issuer = f"https://{os.environ['AUTH0_DOMAIN']}/"
> jwks = jwt.PyJWKClient(f"{issuer}.well-known/jwks.json")
> management = ManagementClient(
>     domain=os.environ["AUTH0_DOMAIN"],
>     client_id=os.environ["AUTH0_M2M_CLIENT_ID"],
>     client_secret=os.environ["AUTH0_M2M_CLIENT_SECRET"],
> )
>
>
> @dataclass
> class VerifiedAccount:
>     account_id: str
>     email: str
>     auth_context: AuthContext
>
>
> def verify_new_account(id_token: str) -> VerifiedAccount:
>     signing_key = jwks.get_signing_key_from_jwt(id_token).key
>     claims = jwt.decode(id_token, signing_key, algorithms=["RS256"], issuer=issuer, audience=os.environ["AUTH0_CLIENT_ID"])
>     user = management.users.get(claims["sub"])
>     if not user.email:
>         raise ValueError(f"Auth0 user {claims['sub']} has no email address")
>     created = user.created_at.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") if user.created_at else None
>
>     return VerifiedAccount(
>         account_id=claims["sub"],
>         email=user.email,
>         auth_context=from_auth0(claims, {"account_created_at": created}),
>     )
> ```
>
> ```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> package main
>
> import (
> 	"context"
> 	"fmt"
> 	"log"
> 	"os"
> 	"time"
>
> 	"github.com/MicahParks/keyfunc/v3"
> 	"github.com/auth0/go-auth0/v3/management"
> 	auth0 "github.com/auth0/go-auth0/v3/management/client"
> 	"github.com/auth0/go-auth0/v3/management/option"
> 	"github.com/golang-jwt/jwt/v5"
> 	noresponse "github.com/noresponsehq/go/v14"
> 	"github.com/noresponsehq/go/v14/models/components"
> )
>
> type verifiedAccount struct {
> 	AccountID   string
> 	Email       string
> 	AuthContext *components.AuthContext
> }
>
> var (
> 	issuer = "https://" + os.Getenv("AUTH0_DOMAIN") + "/"
> 	jwks   keyfunc.Keyfunc
> 	mgmt   *auth0.Management
> )
>
> func init() {
> 	var err error
> 	if jwks, err = keyfunc.NewDefault([]string{issuer + ".well-known/jwks.json"}); err != nil {
> 		log.Fatal(err)
> 	}
> 	credentials := option.WithClientCredentials(context.Background(), os.Getenv("AUTH0_M2M_CLIENT_ID"), os.Getenv("AUTH0_M2M_CLIENT_SECRET"))
> 	if mgmt, err = auth0.New(os.Getenv("AUTH0_DOMAIN"), credentials); err != nil {
> 		log.Fatal(err)
> 	}
> }
>
> func verifyNewAccount(ctx context.Context, idToken string) (verifiedAccount, error) {
> 	token, err := jwt.Parse(idToken, jwks.Keyfunc,
> 		jwt.WithValidMethods([]string{"RS256"}),
> 		jwt.WithIssuer(issuer),
> 		jwt.WithAudience(os.Getenv("AUTH0_CLIENT_ID")),
> 		jwt.WithExpirationRequired())
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	claims := token.Claims.(jwt.MapClaims)
> 	subject, err := claims.GetSubject()
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	usr, err := mgmt.Users.Get(ctx, subject, &management.GetUserRequestParameters{})
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	if usr.GetEmail() == "" {
> 		return verifiedAccount{}, fmt.Errorf("auth0 user %s has no email address", subject)
> 	}
>
> 	authContext, err := noresponse.FromAuth0Claims(claims, map[string]any{
> 		"account_created_at": usr.GetCreatedAt().UTC().Format(time.RFC3339),
> 	})
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	return verifiedAccount{AccountID: subject, Email: usr.GetEmail(), AuthContext: authContext}, nil
> }
> ```

> [tab] Your own login
>
> Use the session that your own login issued. In the samples, `sessions` is the code that verifies your own sessions, and `users` is your user table. The account id is your own user id.
>
> Do not send `authContext`. It is optional, and it carries facts that an auth provider verified. Without it, NoResponse scores only the identifiers. The six [auth facts](https://docs.noresponse.org/guides/auth-session.md#the-auth-facts-and-their-effect) then do not move the score.
>
> ```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> import type { AuthContext } from "@noresponse/node";
>
> // Your own login has no auth provider, so authContext stays undefined.
> export type VerifiedAccount = { accountId: string; email: string; authContext?: AuthContext };
>
> export async function verifyNewAccount(sessionToken: string): Promise<VerifiedAccount> {
>   const session = await sessions.verify(sessionToken); // throws on an expired or forged session
>   const user = await users.get(session.userId);
>   if (!user.email) throw new Error(`user ${user.id} has no email address`);
>
>   return { accountId: user.id, email: user.email };
> }
> ```
>
> ```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> from dataclasses import dataclass
>
> from noresponse import AuthContext
>
>
> @dataclass
> class VerifiedAccount:
>     account_id: str
>     email: str
>     # Your own login has no auth provider, so auth_context stays None.
>     auth_context: AuthContext | None = None
>
>
> def verify_new_account(session_token: str) -> VerifiedAccount:
>     session = sessions.verify(session_token)  # raises on an expired or forged session
>     user = users.get(session.user_id)
>     if not user.email:
>         raise ValueError(f"user {user.id} has no email address")
>
>     return VerifiedAccount(account_id=user.id, email=user.email)
> ```
>
> ```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
> package main
>
> import (
> 	"context"
> 	"fmt"
>
> 	"github.com/noresponsehq/go/v14/models/components"
> )
>
> type verifiedAccount struct {
> 	AccountID string
> 	Email     string
> 	// Your own login has no auth provider, so AuthContext stays nil.
> 	AuthContext *components.AuthContext
> }
>
> func verifyNewAccount(ctx context.Context, sessionToken string) (verifiedAccount, error) {
> 	session, err := sessions.Verify(ctx, sessionToken) // fails on an expired or forged session
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	usr, err := users.Get(ctx, session.UserID)
> 	if err != nil {
> 		return verifiedAccount{}, err
> 	}
> 	if usr.Email == "" {
> 		return verifiedAccount{}, fmt.Errorf("user %s has no email address", usr.ID)
> 	}
> 	return verifiedAccount{AccountID: usr.ID, Email: usr.Email}, nil
> }
> ```

With an auth provider, the adapter reads these facts from the claims: the session id, organisation, roles, second factor and impersonation. [Pass your auth session](https://docs.noresponse.org/guides/auth-session.md) lists each field that each adapter maps, and the session facts that you can add.

### 5. Call NoResponse

Run this in the backend route that grants the credits or the first API key, before it grants them. From here, the code is the same for every auth provider and for your own login.

1. Create the API key of the account and store it inactive.
2. Send the SHA-256 of the key as `issued_credential.sha256`. The key never leaves your backend.
3. Make the Idempotency-Key from the key id.

NoResponse stores the hash. Thus a key that shows up later in abuse or in a leak links back to this account creation. Because the Idempotency-Key comes from the key id, a retry of this call replays the same assessment. It does not start a new one.

If your gate grants credits and no key, do not send `issuedCredential`. Make the Idempotency-Key from your own id for the grant. With your own login, `newAccount.authContext` is empty, and the SDK does not send `auth_context`.

`flow` names the flow that you assess: `account_creation` here, `login` at login and `purchase` at purchase. The samples do not send `depth`. Thus account creation gets the default `full`, which waits up to 3,000 ms for the sources. `quick` waits only for the sources that answer within 500 ms. It is the default for `login`.

In the samples:

* `token` is the token from step 4: the Clerk session token, WorkOS access token, Auth0 ID token or your own session token.
* `clientIp` is the address of the user, as your load balancer reports it.
* `apiKeys` is your own key store.

> [!WARNING]
>
> `ip` must be a public address. The API refuses private, loopback and documentation addresses such as `192.0.2.1` with a 400. Thus a request from your own computer through `localhost` needs a real address in its place. The API accepts `81.2.69.160`.

```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { NoResponse, hashIssuedCredential } from "@noresponse/node";

const nr = new NoResponse(); // reads NORESPONSE_API_KEY

const newAccount = await verifyNewAccount(token);
const newKey = await apiKeys.createInactive(newAccount.accountId); // { id, secret }

const assessment = await nr.assessments.create(
  {
    accountId: newAccount.accountId,
    flow: "account_creation",
    identifiers: { email: newAccount.email, ip: clientIp },
    authContext: newAccount.authContext,
    issuedCredential: { sha256: hashIssuedCredential(newKey.secret) },
  },
  { idempotencyKey: `credit-gate-${newKey.id}` },
);
```

```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
from noresponse import NoResponse, hash_issued_credential

client = NoResponse()  # reads NORESPONSE_API_KEY

new_account = verify_new_account(token)
new_key = api_keys.create_inactive(new_account.account_id)  # .id, .secret

assessment = client.assessments.create(
    account_id=new_account.account_id,
    flow="account_creation",
    identifiers={"email": new_account.email, "ip": client_ip},
    auth_context=new_account.auth_context,
    issued_credential={"sha256": hash_issued_credential(new_key.secret)},
    idempotency_key=f"credit-gate-{new_key.id}",
)
```

```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
client := noresponse.NewClient(os.Getenv("NORESPONSE_API_KEY")) // create it once, at startup

newAccount, err := verifyNewAccount(ctx, token)
if err != nil {
	return err
}
newKey, err := apiKeys.CreateInactive(ctx, newAccount.AccountID) // .ID, .Secret
if err != nil {
	return err
}
sha256, err := noresponse.HashIssuedCredential(newKey.Secret)
if err != nil {
	return err
}

res, err := client.Assessments.Create(ctx, "credit-gate-"+newKey.ID, components.AssessmentRequest{
	AccountID: newAccount.AccountID,
	Flow:      components.FlowAccountCreation,
	Identifiers: components.AssessmentRequestIdentifiers{
		Email: noresponse.Pointer(newAccount.Email),
		IP:    noresponse.Pointer(clientIP),
	},
	AuthContext:      newAccount.AuthContext,
	IssuedCredential: &components.AssessmentRequestIssuedCredential{Sha256: sha256},
})
if err != nil {
	return err
}
assessment := res.Result
```

```bash title="cURL" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl https://api.noresponse.org/v1/assessments \
  -H "Authorization: Bearer $NORESPONSE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: credit-gate-key_01JC4T7W2X" \
  -d '{
    "account_id": "user_2nXk1QmP5rT8vW3yZ6aB9cD0eF4",
    "flow": "account_creation",
    "identifiers": { "email": "jordan.lee@example.com", "ip": "81.2.69.160" },
    "auth_context": {
      "provider": "clerk",
      "issuer": "https://clerk.example.com",
      "subject": "user_2nXk1QmP5rT8vW3yZ6aB9cD0eF4",
      "session_id": "sess_2nXk3HjL7pR1sT5uV9wX2yZ4aB6",
      "account_created_at": "2026-10-21T16:41:48Z",
      "email_verified": true,
      "verified": true,
      "transport": "backend"
    },
    "issued_credential": { "sha256": "828478ea8622f80587130f781c7aba3877b9853d760250da569238b3c06556e1" }
  }'
```

The answer starts with `account`, the one current risk of the account. It holds the score, the decision for this flow and the reasons for them. This is the part that you act on. The facts of this assessment alone are under `detail`, for example its status, confidence and incomplete sources.

```json title="Response" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "schema_version": "1",
  "id": "asm_01M5FNFQWDRBZZMWBPN0WEC40C",
  "status": "partial",
  "flow": "account_creation",
  "depth": "full",
  "account": {
    "schema_version": "1",
    "id": "user_2nXk1QmP5rT8vW3yZ6aB9cD0eF4",
    "risk": {
      "score": 0,
      "decision": "allow",
      "reasons": [
        { "code": "auth_new_account", "direction": "raises", "impact": "low", "identifier": "context" },
        { "code": "no_breach_history", "direction": "neutral", "impact": "none", "identifier": "email" },
        { "code": "auth_email_verified", "direction": "lowers", "impact": "low", "identifier": "context" }
      ]
    },
    "decisions_by_flow": { "account_creation": "allow", "login": "allow", "purchase": "allow" },
    "assessment_id": "asm_01M5FNFQWDRBZZMWBPN0WEC40C",
    "updated_at": "2026-10-21T16:41:50.204Z"
  },
  "detail": {
    "assessment_id": "asm_01M5FNFQWDRBZZMWBPN0WEC40C",
    "account_id": "user_2nXk1QmP5rT8vW3yZ6aB9cD0eF4",
    "status": "partial",
    "confidence": "medium",
    "assessment_version": 1
  }
}
```

`detail` has more fields than shown here. [The assessment](https://docs.noresponse.org/reference/assessment.md) describes each one.

A 4xx answer raises a typed error in every SDK:

* A 400 names the field that it refused in `invalid_params`.
* A 401 means that the key is missing or revoked.
* A 403 means that the key does not have the `assess` scope.

[Errors](https://docs.noresponse.org/reference/errors.md) lists each error.

### 6. Act on the answer

Act on `account.risk.decision`. Your code decides. NoResponse never blocks an account creation itself.

| `account.risk.decision` | What the gate does |
| - | - |
| `block` | Refuse. Revoke the key and grant nothing. A live key gives `block` only after you set a block threshold in the [workspace settings](https://docs.noresponse.org/reference/settings.md#turn-blocking-on). From then on, an account whose score reaches that threshold is `block`. A test key blocks from 90, so `block@test.noresponse.org` tests this branch. |
| `allow` | Activate the key and grant the credits. |
| `step_up` | Keep the key inactive. Ask for a second factor or a verified phone number, through your auth provider or your own login. When the user passes, activate the key and grant the credits. The step-up is the second test, so you make no second call to NoResponse. |
| `review` | Keep the key inactive. Put the account in a queue for a person on your team to approve or refuse. Send their decision to NoResponse with [Report outcomes](https://docs.noresponse.org/guides/outcomes.md). |
| `held` | The flow is [held](https://docs.noresponse.org/guides/late-results.md#held-admission), and the investigation still runs. Keep the key inactive and run the same rules on the final answer. |
| `account` is absent | The first assessment of the account is still pending, so there is no decision yet. Keep the key inactive and run the same rules on the final answer. |

Any decision that the SDK does not recognise goes to review. `apiKeys`, `credits` and `reviewQueue` are your own code.

```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import type { Assessment } from "@noresponse/node";

const FREE_CREDITS = 500;

export type GateResult = "refused" | "granted" | "step_up" | "held" | "pending";

export async function act(assessment: Assessment, accountId: string, keyId: string): Promise<GateResult> {
  const account = assessment.account;
  if (!account) return "pending"; // the account's first assessment is still pending
  switch (account.risk.decision) {
    case "block":
      await apiKeys.revoke(keyId);
      return "refused";
    case "allow":
      await apiKeys.activate(keyId);
      await credits.grant(accountId, FREE_CREDITS);
      return "granted";
    case "step_up":
      return "step_up"; // activate the key and grant the credits after the second factor passes
    case "held":
      return "pending"; // a held flow: the final decision follows
    default:
      await reviewQueue.push({ accountId, keyId, assessmentId: assessment.id });
      return "held";
  }
}
```

```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
from noresponse import Assessment

FREE_CREDITS = 500


def act(assessment: Assessment, account_id: str, key_id: str) -> str:
    if assessment.account is None:
        return "pending"  # the account's first assessment is still pending
    decision = assessment.account.risk.decision
    if decision == "block":
        api_keys.revoke(key_id)
        return "refused"
    if decision == "allow":
        api_keys.activate(key_id)
        credits.grant(account_id, FREE_CREDITS)
        return "granted"
    if decision == "step_up":
        return "step_up"  # activate the key and grant the credits after the second factor passes
    if decision == "held":
        return "pending"  # a held flow: the final decision follows
    review_queue.push(account_id, key_id, assessment.id)
    return "held"
```

```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const freeCredits = 500

func act(ctx context.Context, a *components.Assessment, accountID, keyID string) (string, error) {
	if a.Account == nil {
		return "pending", nil // the account's first assessment is still pending
	}
	switch a.Account.Risk.Decision {
	case components.AccountDecisionBlock:
		return "refused", apiKeys.Revoke(ctx, keyID)
	case components.AccountDecisionAllow:
		if err := apiKeys.Activate(ctx, keyID); err != nil {
			return "", err
		}
		return "granted", credits.Grant(ctx, accountID, freeCredits)
	case components.AccountDecisionStepUp:
		return "step_up", nil // activate the key and grant the credits after the second factor passes
	case components.AccountDecisionHeld:
		return "pending", nil // a held flow: the final decision follows
	default:
		return "held", reviewQueue.Push(ctx, accountID, keyID, a.ID)
	}
}
```

Call `act` with the answer from step 5. When it returns `pending`, do these steps:

1. Tell the user that you are setting up the account.
2. In a background job, wait for the final answer.
3. Call `act` again.

`wait` polls until the status of the assessment is `complete`. It polls at the interval that the `Retry-After` of the API gives, and at most once a second. It stops after a timeout, 30 seconds unless you set a different one.

* If the answer is `partial` at the timeout, `wait` returns it with its status still `partial`. `act` then runs on its recommendation.
* If the answer is still `pending`, `wait` raises a timeout error that carries the pending answer.

If you prefer not to poll, the [`account.risk_changed` webhook](https://docs.noresponse.org/guides/webhooks#account-risk_changed) delivers the final decision.

```ts title="TypeScript" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const result = await act(assessment, newAccount.accountId, newKey.id);
if (result === "pending") {
  // In a background job: wait polls until the answer is complete, for up to 30 s.
  const settled = await nr.assessments.wait(assessment.id);
  await act(settled, newAccount.accountId, newKey.id);
}
```

```python title="Python" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
result = act(assessment, new_account.account_id, new_key.id)
if result == "pending":
    # In a background job: wait polls until the answer is complete, for up to 30 s.
    settled = client.assessments.wait(assessment.id)
    act(settled, new_account.account_id, new_key.id)
```

```go title="Go" theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
result, err := act(ctx, &assessment, newAccount.AccountID, newKey.ID)
if err != nil {
	return err
}
if result == "pending" {
	// In a background job: WaitForAssessment polls until the answer is complete,
	// until ctx's deadline or for up to 30 s.
	settled, err := noresponse.WaitForAssessment(ctx, client, assessment.ID, nil)
	if err != nil {
		return err
	}
	if _, err := act(ctx, settled, newAccount.AccountID, newKey.ID); err != nil {
		return err
	}
}
```

A timeout, a 429 or a 503 from NoResponse also has no decision. The SDKs retry those for up to 30 seconds, and then raise an error. Keep the key inactive. From a background job, retry `assessments.create` with the same key, the same body and the same Idempotency-Key.

> [!WARNING]
>
> Do not run the full gate again. That creates a second key and a second assessment.

### 7. Check it on the simulator

Keep the test key set. Create one account for each row below, with the email as the address of the user. The route calls `verifyNewAccount`, then NoResponse, then `act`.

Log the `id` of each answer. It starts with `asm_`. If the answer has an `account`, also log `account.risk.score` and `account.risk.decision`. A first answer that is still pending has no `account`. To use an address again for a different account, add a `+tag`, as in `allow+2@test.noresponse.org`.

| Create an account with | `act` returns |
| - | - |
| `allow@test.noresponse.org` | `granted` |
| `step_up@test.noresponse.org` | `step_up` |
| `review@test.noresponse.org` | `held` |
| `block@test.noresponse.org` | `refused` |
| `late@test.noresponse.org` | `granted` on the first answer. The final answer, about 5 seconds later, is `review`. |

The last row is the late result: an answer that has more risk after the gate acted. The gate on this page acts on the first answer, so it grants. The final answer raises the account's decision to `review`, and NoResponse sends [`account.risk_changed`](https://docs.noresponse.org/guides/webhooks). [Admission and late decisions](https://docs.noresponse.org/guides/late-results.md) shows how the SDK enforces it.

With your own login, give the SDK one function for each action, as [Your own login](https://docs.noresponse.org/guides/late-results.md#your-own-login) shows.

> [!TIP]
>
> Every simulated answer carries a `test_scenario` reason. Use it to tell a simulated answer from a live one.

### 8. Go live

1. Set `NORESPONSE_API_KEY` to the live key from your verified email (step 1).
2. Create a new account with your own email address.

NoResponse now assesses the answer against real sources. Its score comes from what the sources find, and it carries no `test_scenario` reason. A second account with the same email fires the `seen_before` reason. For a clean first answer, use a new address.

Every answer carries an `X-Request-ID` header. Quote it, or the assessment `id`, when you write to us about an answer.

To examine an answer, open the [console](https://app.noresponse.org) and find its `asm_` id on **Assessments**. You can also press ⌘K and paste the id. The assessment shows its score and reasons, its account, and the websites that held each identifier.

## Next steps

> [card] [Turn an assessment into a decision](https://docs.noresponse.org/guides/decisions.md)
>
> Tune the rules. Add rules on reasons and confidence.

> [card] [Webhooks](https://docs.noresponse.org/guides/webhooks.md)
>
> Receive late answers.

> [card] [Pass your auth session](https://docs.noresponse.org/guides/auth-session.md)
>
> Send the session facts that the quickstart does not send.

> [card] [Report outcomes](https://docs.noresponse.org/guides/outcomes.md)
>
> Tell NoResponse the outcome of each account, so that later scores improve.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.