OC Connect
Add orangecheck to your existing login. Keep Auth0, Clerk, NextAuth, Google, email/password — whatever you already run. It works exactly as it does today. Drop in one server-side call so that when your user signs in, an orangecheck account is created for them at the same time.
A Connect integration is one server-side call: connectProvision from
@orangecheck/me-client 0.39.0 or later, connect_provision from
the orangecheck Python package 2.13.0 or later, or one HTTPS POST from any
language.
New to orangecheck integration? See the
Integration overview first — Connect is one of two pathways.
If you'd rather orangecheck be your sign-in (no login of your own), that's
the sign-in popup from @orangecheck/me-client: see the
Quickstart.
How it worksLink to this section
- Open your project at ochk.app/me/projects (opens in a new tab) and turn on Your own login on its Sign-in page: you get an API key. orangecheck sign-in is a separate switch beside it, so a project can offer both (see Both on one project).
- Your user signs in however they already do. Nothing changes.
- Right after, your backend calls
connectProvision(it posts tohttps://ochk.io/api/connect/provision) with your API key and your own id for that user. - OrangeCheck returns the account id (
did_oc). Store it on your user record.
The whole integrationLink to this section
// When you make a user's record, after their first sign-in your own way.
// Run this from your backend: it refuses to run in a browser.
import { connectProvision } from '@orangecheck/me-client/server';
declare const yourUser: { id: string }; // the user you just made
const r = await connectProvision({
apiKey: process.env.OCHK_CONNECT_KEY!,
userId: yourUser.id,
});
if (r.ok) {
// store r.did_oc on your user record — that is the whole integration.
}
OCHK_CONNECT_KEY is the API key from your project's Sign-in page at
ochk.app. userId is your own stable id for the user. That is everything — no
token to forward, no provider to name, no keypair, no redirect.
In Python:
import os
from orangecheck import connect_provision
user_id: str # the user you just made
result = connect_provision(os.environ["OCHK_CONNECT_KEY"], user_id)
if result.ok:
did_oc = result.did_oc # store it on your user record
Call it once per user and keep the did_oc; there is no need to call it on
every sign-in. It is idempotent, so a retry after a timeout is safe: the same
user always resolves to the same did:oc (is_new tells you whether this call
created it). A call makes no record of when your user signed in.
It never blocks your sign-in. A refusal or an outage is a result,
{ ok: false, reason, status }, never a throw, and a call gives up after five
seconds (timeoutMs in Node, timeout in Python, at most 30). Only a mistake
in the call itself throws, before anything is sent: an option it does not read,
a missing key or user id, or consent: false.
Without an SDK, it is one request:
declare const yourUser: { id: string }; // the user you just made
const res = await fetch('https://ochk.io/api/connect/provision', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.OCHK_CONNECT_KEY}`,
},
body: JSON.stringify({ user_id: yourUser.id }),
});
const { did_oc, is_new } = await res.json();
With or without askingLink to this section
You choose one of two ways, per site:
-
Without asking. Every user who signs in gets an account, made by the call above with no
consent. It is identity only: it can't be paid. -
With an opt-in box. On your sign-in or sign-up, show a checkbox with these words, exactly:
Also create my orangecheck account
It stays with orangecheck until you claim it at ochk.app. Then you can use it on other sites, or delete it.
Both SDKs export them:
CONNECT_CONSENT_LABELandCONNECT_CONSENT_BLURB, from@orangecheck/me-client/connect-consent(no dependencies, safe in any bundle) and fromorangecheck.
The rules for the box:
- Unticked by default. Never pre-tick it, and never bundle it with your Terms or with any other box.
- Unticked means no call at all. Don't call
connectProvisionfor that user. The SDKs refuseconsent: false, because a call without consent makes an account the person did not ask for. - Ticked means
consent: true, sent only on a tick, at the moment of the tick. It is recorded once. - A later tick upgrades. If you started without asking and later offer the
box (in account settings, say), a tick calls again with
consent: true: the samedid_oc, now consented. - After a deletion, provision answers
410 account_deleteduntil the person ticks the box again. - Before a claim, deleting it is yours to do. The person can delete the
account at ochk.app only once they have claimed it. Until then, delete it with
connectDeletewhen they delete their account with you (below).
A site that will pay its users asks first.
In plain HTML, the words go in as text:
<label>
<input type="checkbox" name="orangecheck" />
Also create my orangecheck account
</label>
<p>
It stays with orangecheck until you claim it at ochk.app. Then you can use
it on other sites, or delete it.
</p>
In React, import them:
import type { ReactElement } from 'react';
import {
CONNECT_CONSENT_BLURB,
CONNECT_CONSENT_LABEL,
} from '@orangecheck/me-client/connect-consent';
export function OrangecheckOptIn(): ReactElement {
return (
<div>
<label>
<input type="checkbox" name="orangecheck" />
{CONNECT_CONSENT_LABEL}
</label>
<p>{CONNECT_CONSENT_BLURB}</p>
</div>
);
}
On your server, call only on a tick:
import { connectProvision } from '@orangecheck/me-client/server';
declare const yourUser: { id: string }; // the user who just signed up
declare const form: FormData; // the sign-up form they sent
if (form.get('orangecheck') === 'on') {
const r = await connectProvision({
apiKey: process.env.OCHK_CONNECT_KEY!,
userId: yourUser.id,
consent: true,
});
if (r.ok) {
// store r.did_oc on your user record
}
}
// unticked: no call at all
In Python:
import os
from orangecheck import CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, connect_provision
# Render CONNECT_CONSENT_LABEL and CONNECT_CONSENT_BLURB beside an unticked box.
user_id: str # the user who just signed up
ticked: bool # whether they ticked it
if ticked:
result = connect_provision(os.environ["OCHK_CONNECT_KEY"], user_id, consent=True)
if result.ok:
did_oc = result.did_oc # store it on your user record
# unticked: no call at all
What you get backLink to this section
{ "ok": true, "did_oc": "did:oc:…", "is_new": true }
Or a refusal, { "ok": false, "reason": … }. The SDKs return the same reasons,
and unavailable for an outage, a timeout or an answer they can't read:
410 account_deleted: this user's account was deleted, by the person or by you (below). Stop. Provision them again only when they have just asked for an orangecheck account again, by ticking your consent box, withconsent: true.429 daily_limit: your app made 1,000 new accounts in the last 24 hours. Existing users still get theirdid_oc. Try a new one later, or write to us to raise it.429 rate_limited,401 invalid_api_key,403 app_suspended: as named.
The provisioned account is orangecheck-issued: the user holds no signing key
of their own on this path, so orangecheck holds the account and anything that
accrues to it. Federation custody, then the user's own keys, is where that goes
— it is the design and it is not live. The machine-readable state is
/api/federations (opens in a new tab); the long form is
federation custody. You now know "my user ↔ this orangecheck
account" and can show it, or call other orangecheck APIs on their behalf.
Both on one projectLink to this section
A project can offer orangecheck sign-in and keep your own login at the same time. They are two switches on the project, and turning one on never turns the other off. The two meet in one place:
- Someone who signs in with orangecheck already has an account. Store the
did:octheir sign-in gave you on your user record, and do not callconnectProvisionfor them. Provisioning them as well would make them a second account. - Call provision only for people who come in through your own login.
Turning on your own login changes nothing for orangecheck sign-in: its sign-in rule and revocation list work as before, and your project's webhooks hear about people from both.
Run the whole funnel yourself: open example sites in Node and Python that do both, and run offline with no account.
Paying your users, and how they claim itLink to this section
Fire billable events for a provisioned user with
their did_oc as user_address, signed with your project's secret. What they
earn waits in that account. Nobody can sign in to it, so to see and cash it out
the person claims it into an orangecheck account of their own, at ochk.app.
Only an account whose person agreed can earn: one you provisioned with
consent: true, or one they claimed. An event naming any other is refused with
403 connect_consent_required, and nothing is recorded or charged. me.ochk.io
checks consent with ochk.io, at most once a month for an account that has it. If
that check cannot be made, the event gets 503 connect_state_unavailable, also
with nothing recorded, so retry it later.
A claim link. When your signed-in user asks to claim, mint a link from your backend and send them to it:
import { connectClaimLink } from '@orangecheck/me-client/server';
declare const yourUser: { id: string }; // the signed-in user asking to claim
const r = await connectClaimLink({
apiKey: process.env.OCHK_CONNECT_KEY!,
userId: yourUser.id,
});
if (r.ok) {
// redirect this user, and only this user, to r.url (https://ochk.app/connect/claim#t=…)
}
The link works once, for fifteen minutes, and a new one closes the one before
it. Its token is in the URL fragment, so it reaches no server log; treat it as a
secret anyway, and mint it only for the user you have just signed in. A user you
never provisioned answers 404 unknown_user; an account already claimed answers
409 already_claimed. It can also answer 429 rate_limited,
401 invalid_api_key, 403 app_suspended and 400 bad_request; the SDKs
return anything else, an outage or a timeout as unavailable.
A verified email. Pass email_verified: true with email when you checked
the address yourself (a code or a link the user answered). Someone who signs in
to ochk.app with that address, verified, is offered the claim on their account
page, under your project's domain. That offer needs your domain verified and
your Connect app linked to the project (both on the project's sign-in page),
because an app's own name is whatever its maker typed. Without email_verified,
an email proves nothing, because it could be anyone's, and only a claim link
works.
An address verified once may be someone else's today, so the offer names only
the address, masked, until the person enters a code we email to it. Only then do
they see your site and what the account holds. A call that names no email leaves
the offer as it was. Send email: null, or the address without
email_verified: true, when it is no longer this user's, and the offer is
withdrawn.
Either way, ochk.app shows the person what the account holds before anything changes. A link claim then asks for a passkey tap or an ochk.io confirmation; an email claim has the code. Then:
/api/connect/provisionkeeps returning the samedid_ocfor that user. Keep firing events for it; they land with the person.- Your project's webhooks get a
connect.claimednotice ({ kind: 'oc-system-event', subtype: 'connect.claimed', did_oc, sub }), naming the account by thedid_ocyou hold. - You are never told the id of the account it was joined to, so two sites a person claims from cannot link them through one id.
In Python:
import os
from orangecheck import connect_claim_link
user_id: str # your own id for the signed-in user asking to claim
result = connect_claim_link(os.environ["OCHK_CONNECT_KEY"], user_id)
if result.ok:
url = result.url # redirect this user to it
When your user deletes their accountLink to this section
Delete the one you made for them, from your backend:
import { connectDelete } from '@orangecheck/me-client/server';
declare const yourUser: { id: string }; // the user who is leaving
const r = await connectDelete({
apiKey: process.env.OCHK_CONNECT_KEY!,
userId: yourUser.id,
});
// r.ok: r.result is 'deleted', 'detached' or 'already_deleted'
In Python, connect_delete(api_key, user_id) returns the same.
deleted: nobody had claimed it, so it is gone.detached: the person claimed it, so it is theirs and stays. It is no longer yours: your user id no longer reaches it.already_deleted: nothing left to do.409 holds_earnings: nobody claimed it, but it earned. That is the person's, so it stays; send them a claim link before they go.404 unknown_user: you never provisioned this user.409 not_deletable: orangecheck keeps this account for a reason of its own, so nothing was deleted, and asking again gives the same answer.429 rate_limited,401 invalid_api_key,400 bad_request: as named. The SDKs return anything else, an outage or a timeout asunavailable.
When deleting refusesLink to this section
Delete your own account for this user only when connectDelete returned one of
these. Every other answer pauses deleting, with nothing deleted.
Delete your own account on exactly these:
{ ok: true, result: 'deleted' }: gone. Tell them their account is deleted.{ ok: true, result: 'detached' }or{ ok: true, result: 'already_deleted' }: already gone from your side. Tell them their account is deleted.{ ok: false, reason: 'unknown_user' }: you never provisioned them. Tell them their account is deleted.{ ok: false, reason: 'holds_earnings' }or{ ok: false, reason: 'not_deletable' }: it stays theirs. Tell them their account with you is deleted, and their orangecheck account stays theirs at ochk.app (opens in a new tab). Asking again gives the same answer.
Pause, with nothing deleted, on everything else:
{ ok: false, reason: 'unavailable' }(an outage, a timeout, orstatus: 0when nothing came back),{ ok: false, reason: 'rate_limited' }, or it threw: tell them to try again in a few minutes. Nothing to fix.- No key to call it with,
{ ok: false, reason: 'invalid_api_key' },{ ok: false, reason: 'bad_request' }, or anyresultorreasonyour code does not know, a later SDK's included: tell them deleting is paused on your side and nothing was deleted. Then alert yourself: it is your key, your code, or an SDK newer than your code, not the person.
Every refusal also carries status, ochk.io's HTTP status. connectDelete
throws only for a mistake in your call, so check the key yourself before you
call it, as below.
import type { ConnectDeleteResult } from '@orangecheck/me-client/server';
import { connectDelete } from '@orangecheck/me-client/server';
export type AfterDelete =
| 'delete'
| 'delete_stays_at_ochk_app'
| 'try_again'
| 'setup';
// An allow-list: anything not named here deletes nothing.
export function afterConnectDelete(r: ConnectDeleteResult): AfterDelete {
if (r.ok) {
const gone =
r.result === 'deleted' ||
r.result === 'detached' ||
r.result === 'already_deleted';
return gone ? 'delete' : 'setup';
}
if (r.reason === 'unknown_user') return 'delete';
if (r.reason === 'holds_earnings' || r.reason === 'not_deletable') {
return 'delete_stays_at_ochk_app';
}
if (r.reason === 'unavailable' || r.reason === 'rate_limited')
return 'try_again';
return 'setup'; // invalid_api_key, bad_request, and any reason added later
}
declare function deleteOwnAccount(userId: string): Promise<void>;
declare function alertYourself(message: string): Promise<void>;
export async function onUserDeletes(userId: string): Promise<string> {
const apiKey = process.env.OCHK_CONNECT_KEY;
let next: AfterDelete;
if (!apiKey) {
next = 'setup';
} else {
try {
next = afterConnectDelete(await connectDelete({ apiKey, userId }));
} catch {
next = 'try_again';
}
}
switch (next) {
case 'delete':
await deleteOwnAccount(userId);
return 'Your account is deleted.';
case 'delete_stays_at_ochk_app':
await deleteOwnAccount(userId);
return 'Your account here is deleted. Your orangecheck account stays yours at ochk.app.';
case 'try_again':
return 'We could not delete your account just now. Try again in a few minutes.';
case 'setup':
await alertYourself(
'Connect delete paused: check OCHK_CONNECT_KEY and the me-client version'
);
return 'Deleting accounts is paused on our side. Nothing was deleted.';
}
}
In Python, connect_delete returns the same ok, result and reason values,
so the same table applies.
A daily canary. Once a day, call connectDelete for a user id you never
provisioned, such as oc-canary-never-a-user. It must answer
{ ok: false, reason: 'unknown_user' }; nothing is deleted or recorded.
Anything else means deleting would fail for real users too: invalid_api_key is
your key, unavailable is an outage. Alert yourself on either.
After any of these, provision answers 410 account_deleted for that user. The
same happens when the person deletes their orangecheck account themselves.
An app can't be deleted while accounts it made are still unclaimed
(409 has_unclaimed_accounts): delete those users first.
What to tell your usersLink to this section
Your users get an orangecheck account because they use your site. Say so where you describe your sign-in, in your words, and keep these facts:
- Signing in to your site makes an orangecheck account for them, or, with a consent box, only when they tick it.
- orangecheck keeps an id for them made from your user id, and their email only as a keyed hash, if you send it. It keeps no record of when they sign in.
- You get an id for that account, not anything else about them.
- They can claim it at ochk.app, from a claim link you give them. When they delete their account with you, you delete this one too (above).
NotesLink to this section
- Server-to-server only. Call
/api/connect/provision,/api/connect/claim-linkand/api/connect/deletefrom your backend, never the browser. The API key must stay secret: import the me-client calls only from server code that never reaches a client bundle. They refuse to run where there is adocument, which catches the commonest slip but is not a guard. - Limits. 1,000 new accounts a day per app, and 20 apps per account.
- Your user id is 1 to 256 characters, counted in UTF-16 code units.
- No redirects. These endpoints never redirect, so the SDKs treat a redirect as an error: the key goes to ochk.io and nowhere else.
- Unknown options are refused before anything is sent: me-client throws, and
Python raises
TypeError. - The key is shown once. Save it when you register the app. Lost it? Replace it on your project's Sign-in page at ochk.app; the old key stops working immediately.
- Optional
emailandemail_verified. Pass the user's email, andemail_verified: trueonly when you verified it, to let them claim by signing in with it (above). We keep only a keyed hash of the address, never the address. The base call needs neither. Leaveemailout and the last offer stands;email: nulltakes it back. - An integrator can only ever create and manage its own users' orangecheck accounts — a Connect key can never reach into anyone else's account.
Choose Your own login under Sign-in on your first project at ochk.app/me/projects (opens in a new tab).