Sign in with Xcojo
Xcojo Accounts is an OpenID Connect provider. Here’s everything a product needs.
Quickstart
Start sign-in (PHP)
session_start();
$_SESSION['state'] = bin2hex(random_bytes(32));
$_SESSION['nonce'] = bin2hex(random_bytes(32));
header('Location: https://accounts.xcojo.com/sso/authorize.php?' . http_build_query([
'response_type' => 'code',
'client_id' => getenv('XCOJO_SSO_CLIENT_ID'),
'redirect_uri' => getenv('XCOJO_SSO_REDIRECT_URI'),
'scope' => 'openid profile email',
'state' => $_SESSION['state'],
'nonce' => $_SESSION['nonce'],
]));Callback
if (!hash_equals($_SESSION['state'] ?? '', $_GET['state'] ?? '')) exit('Invalid state');
// Exchange the one-time code (valid 2 minutes) for an access token (valid 5 minutes)
$token = post_json('https://accounts.xcojo.com/sso/token.php', [
'client_id' => getenv('XCOJO_SSO_CLIENT_ID'), 'client_secret' => getenv('XCOJO_SSO_CLIENT_SECRET'),
'code' => $_GET['code'], 'redirect_uri' => getenv('XCOJO_SSO_REDIRECT_URI'),
]);
// Read the profile
$me = get_json('https://accounts.xcojo.com/sso/userinfo.php', ['Authorization: Bearer ' . $token['access_token']]);
// $me['sub'] is the stable Xcojo ID — key your users on it, not on email.
Platform APIs
One API key (xk_live_…) works with every platform API. Create keys in API keys and send them as Authorization: Bearer <key> (or X-Xcojo-Key). Responses are JSON with ok; limits reset at midnight UTC and are reported in X-RateLimit-* headers.
| Endpoint | What it does | Free / day | Pro / day |
|---|---|---|---|
https://astromark.xcojo.com/api/v1/geocode.php?q=Bole+Medhanialem | Search addresses and places (Astromark learns from every answer) | 1,000 | 50,000 |
https://astromark.xcojo.com/api/v1/reverse.php?lat=9.01&lng=38.76 | The address at a point | 1,000 | 50,000 |
https://astromark.xcojo.com/api/v1/route.php?from=9.03,38.74&to=8.99,38.79&mode=car | Driving, walking or cycling routes with turn-by-turn steps | 200 | 10,000 |
https://astromark.xcojo.com/api/v1/places.php?lat=9.01&lng=38.76&q=pharmacy | Places near a point | 500 | 20,000 |
https://astromark.xcojo.com/api/v1/position.php | POST live positions for your fleet; GET who’s near a point (Pro) | — | 50,000 |
https://astromark.xcojo.com/tiles/{z}/{x}/{y}.png | Map tiles for Leaflet, MapLibre or any slippy map (no key needed) | Fair use | Fair use |
https://verification.xcojo.com/api/v1/check.php?code=ABCDE-FGHJK | Is a document verified? Who issued it, when, and is it still valid | 500 | 20,000 |
https://jolt.xcojo.com/api/v1/news.php?country=ET&category=business | Latest stories from Jolt news and channels | 1,000 | 25,000 |
https://dev.xcojo.com/api/v1/ai.php | Xcojo AI chat completions — POST {"messages":[…]} (Pro) | — | 1,000 |
Example — geocode and route (JavaScript, from your server)
const H = { Authorization: 'Bearer ' + process.env.XCOJO_API_KEY };
const g = await (await fetch('https://astromark.xcojo.com/api/v1/geocode.php?q=' + encodeURIComponent('Bole Medhanialem, Addis Ababa'), { headers: H })).json();
const p = g.results[0];
const r = await (await fetch(`https://astromark.xcojo.com/api/v1/route.php?from=${p.lat},${p.lng}&to=9.0054,38.7636&mode=car`, { headers: H })).json();
console.log(r.routes[0].distance_m, r.routes[0].duration_s);Example — check a verified document (PHP)
$r = json_decode(file_get_contents('https://verification.xcojo.com/api/v1/check.php?code=' . urlencode($code), false, stream_context_create(['http' => ['header' => 'Authorization: Bearer ' . getenv('XCOJO_API_KEY')]])), true);
if ($r['ok'] && $r['state'] === 'valid') echo 'Issued by ' . $r['issuer']['name'];API reference
| Endpoint | Method | Purpose |
|---|---|---|
https://accounts.xcojo.com/.well-known/openid-configuration | GET | Discovery document with every endpoint below |
https://accounts.xcojo.com/sso/authorize.php | GET | Starts sign-in. Params: response_type=code, client_id, redirect_uri, scope, state, nonce |
https://accounts.xcojo.com/sso/token.php | POST (JSON) | Code → access token. Body: client_id, client_secret, code, redirect_uri |
https://accounts.xcojo.com/sso/userinfo.php | GET | Profile for a bearer token: sub, first_name, last_name, connect_handle, email, avatar_url |
https://accounts.xcojo.com/sso/jwks.php | GET | Public keys for verifying ID token signatures (RS256) |
https://accounts.xcojo.com/api/sso_validate.php | POST (JSON) | Single sign-on: validate a visitor’s xco_sso cookie. Body: client_id, client_secret, sso_token |
https://accounts.xcojo.com/api/logout.php | GET | Ends the visitor’s Xcojo session everywhere |
Single sign-on across *.xcojo.com
People signed in to any Xcojo product carry a xco_sso cookie for .xcojo.com. Your server can recognise them without a redirect:
$r = post_json('https://accounts.xcojo.com/api/sso_validate.php', [
'client_id' => getenv('XCOJO_SSO_CLIENT_ID'),
'client_secret' => getenv('XCOJO_SSO_CLIENT_SECRET'),
'sso_token' => $_COOKIE['xco_sso'] ?? '',
]);
if ($r['ok']) { /* $r['user']['xcojo_uid'], first_name, connect_handle … */ }sub · rotate the secret if it ever leaks.Payments & Ads APIs
Sponsored placements (Xcojo Ads)
First-party pages on *.xcojo.com can request contextual, location-targeted ads. No personal data is sent; location is worked out by Xcojo from the network.
GET https://ads.xcojo.com/api/serve.php?placement=xcojo_sites&q=coffee&lang=en&n=1
{ "ok": true, "ads": [ { "label": "Sponsored", "advertiser": "…", "headline": "…",
"description": "…", "display_url": "…", "click_url": "…", "why": "…" } ] }Show label at the same size as the headline, link the whole ad to click_url, and offer why behind a “Why this ad?” control.
Xcojo Payments
Xcojo products share one double-entry ledger: people hold balances, top up with Chapa or Stripe, send money and withdraw. Partner products can send people to https://pay.xcojo.com/add.php to add money. A public merchant API (charges, refunds, webhooks for third-party apps) is on the roadmap.
Design & assets
Every Xcojo surface follows Connect Design: EB Garamond, the shared colour foundation, one accent, line icons, calm motion. Assets are served by https://dev.xcojo.com.
| Asset | URL |
|---|---|
| Fonts (EB Garamond) | https://dev.xcojo.com/Fonts/?family=EB+Garamond:wght@400;500;600;700 |
| Xcojo logo | https://dev.xcojo.com/Logo/Xcojo%20logo.png |
| Xcojo mark | https://dev.xcojo.com/Logo/X%20logo%20xcojo.png |
| Favicon set | https://dev.xcojo.com/Favicon/?type=favicon · ?type=size&size=32 · ?type=apple · ?type=manifest |
| Icons | https://dev.xcojo.com/Icon/?name=search&size=24&color=currentColor |
| Sounds | https://dev.xcojo.com/Audio/?sound=signature |
| Haptics | https://dev.xcojo.com/Haptic/?pattern=selection (returns {"web":[…]}) |
<link rel="stylesheet" href="https://dev.xcojo.com/Fonts/?family=EB+Garamond:wght@400;500;600;700&display=swap">
:root { --c-bg:#FAF8F3; --c-surface:#FFFFFF; --c-text:#1C1A16; --c-muted:#5C574D; --c-border:#E6E1D6; --xco-accent:#0F766E; }
@media (prefers-color-scheme: dark) { :root { --c-bg:#0E0D0B; --c-surface:#1A1815; --c-text:#F2EEE4; --c-muted:#A8A194; --c-border:#2E2B25; } }