codai docs
Referință API

API-ul Auth (OIDC)

Suprafața publică pentru integratori a auth.codai.ro: discovery, authorization code + PKCE, device flow, tokenuri, logout și /connect/key.

auth.codai.ro e un OpenID Provider standard; citește mai întâi /.well-known/openid-configuration și lasă biblioteca ta OIDC să conducă restul. Singurul endpoint specific codai e GET /connect/key: schimbi access token-ul pe o cheie de inferență cu scope-uri (base_url: https://ai.codai.ro/v1). Sunt listate doar endpoint-urile pe care le apelează un integrator — UI-ul de login/consimțământ, API-ul de cont și rutele aplicației native sunt interne first-party. Erorile OIDC sunt { "error", "error_description" }. Fluxul pas cu pas: fluxul connect, scope-uri: scope-uri.

GET
/.well-known/openid-configuration

Corpul răspunsului

Metadatele provider-ului.

application/json
  1. response

Subsetul documentului de discovery pe care se bazează integratorii; documentul live conține mai multe chei.

issuer*string
Formaturi
authorization_endpoint*string
Formaturi
token_endpoint*string
Formaturi
userinfo_endpoint?string
Formaturi
jwks_uri*string
Formaturi
introspection_endpoint?string
Formaturi
revocation_endpoint?string
Formaturi
device_authorization_endpoint?string
Formaturi
end_session_endpoint?string
Formaturi
registration_endpoint?string

Înregistrare dinamică de clienți pentru clienții MCP publici (nedocumentată aici).

Formaturi
response_types_supported*array<string>
grant_types_supported?array<string>
token_endpoint_auth_methods_supported?array<string>
scopes_supported?array<string>
claims_supported?array<string>
code_challenge_methods_supported?array<string>
acr_values_supported?array<string>
subject_types_supported*array<string>
id_token_signing_alg_values_supported*array<string>
backchannel_logout_supported?boolean
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/.well-known/openid-configuration'
Exemplu de răspuns200
{  "issuer": "https://auth.codai.ro",  "authorization_endpoint": "http://example.com",  "token_endpoint": "http://example.com",  "userinfo_endpoint": "http://example.com",  "jwks_uri": "http://example.com",  "introspection_endpoint": "http://example.com",  "revocation_endpoint": "http://example.com",  "device_authorization_endpoint": "http://example.com",  "end_session_endpoint": "http://example.com",  "registration_endpoint": "http://example.com",  "response_types_supported": [    "string"  ],  "grant_types_supported": [    "string"  ],  "token_endpoint_auth_methods_supported": [    "string"  ],  "scopes_supported": [    "string"  ],  "claims_supported": [    "string"  ],  "code_challenge_methods_supported": [    "S256"  ],  "acr_values_supported": [    "string"  ],  "subject_types_supported": [    "string"  ],  "id_token_signing_alg_values_supported": [    "string"  ],  "backchannel_logout_supported": true}
GET
/jwks

Corpul răspunsului

JSON Web Key Set.

application/json
  1. response
keys*array<>
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/jwks'
Exemplu de răspuns200
{  "keys": [    {      "kty": "RSA",      "kid": "string",      "use": "sig",      "alg": "RS256",      "n": "string",      "e": "string"    }  ]}
GET
/auth

Parametri query

response_type*"code"

Trebuie să fie code.

Valoare din"code"
client_id*string

Identificatorul clientului înregistrat.

redirect_uri*string

Unul dintre redirect URI-urile înregistrate ale clientului (potrivire exactă).

Formaturi
scope*string

Scope-uri separate prin spațiu; trebuie să includă openid.

state?string

Valoare CSRF opacă, întoarsă la redirect. Puternic recomandată.

code_challenge*string

BASE64URL(SHA-256(code_verifier)) — PKCE este obligatoriu pentru fiecare client.

code_challenge_method*"S256"

Doar S256 este suportat.

Valoare din"S256"
nonce?string

Protecție anti-replay, copiată în ID token.

prompt?string

Valorile standard OIDC pentru prompt (login, consent, none, select_account).

acr_values?string

Contextul de autentificare cerut; passkey/mfa declanșează step-up.

resource?string

Indicator de resursă RFC 8707. https://ai.codai.ro/mcp produce un access token JWT cu scope-ul mcp.

Formaturi
mode?"signup"

Extensie codai — signup deschide direct formularul de înregistrare.

Valoare din"signup"
ref?string

Extensie codai — cod de recomandare (codai.ro/r/<username>, 3–20 caractere [A-Za-z0-9_]) precompletat la înregistrare.

Potrivire^[A-Za-z0-9_]{3,20}$
lang?string

Limba paginilor de login. Implicit din cookie-ul NEXT_LOCALE, apoi din Accept-Language.

Valoare din"ro""en"

Corpul răspunsului

Redirect către interfața codai de login/consimțământ sau înapoi la redirect_uri cu code+state (sau error).

Exemplu de cerere
curl -X GET 'https://auth.codai.ro/auth?response_type=code&client_id=metu&redirect_uri=http%3A%2F%2Fexample.com&scope=openid+email+profile+inference+keys%3Amanage&code_challenge=string&code_challenge_method=S256'
Exemplu de răspuns
Gol
POST
/device/auth

Corpul cererii

application/x-www-form-urlencoded
  1. body
client_id*string
scope?string

Scope-uri separate prin spațiu.

resource?string

Indicator de resursă RFC 8707, opțional.

Formaturi

Corpul răspunsului

Autorizarea de dispozitiv a fost emisă.

application/json
  1. response
device_code*string
user_code*string

Afișat utilizatorului; format ****-****.

verification_uri*string
Formaturi
verification_uri_complete*string

verification_uri cu user_code precompletat.

Formaturi
expires_in*integer

Secunde până expiră device code-ul.

interval?integer

Numărul minim de secunde între interogările la /token.

Exemplu de cerere
curl -X POST 'https://auth.codai.ro/device/auth' \  -H 'Content-Type: application/x-www-form-urlencoded' \  -d 'client_id=codai-cli'
Exemplu de răspuns
{  "device_code": "string",  "user_code": "BCDF-GHJK",  "verification_uri": "https://auth.codai.ro/device",  "verification_uri_complete": "http://example.com",  "expires_in": 0,  "interval": 5}
POST
/token

Autorizare

clientSecretBasic
headerAutorizareBasic <token>

Autentificare client client_secret_basic. client_secret_post și private_key_jwt merg în body-ul formularului; clienții publici trimit doar client_id.

Corpul cererii

application/x-www-form-urlencoded
  1. body

Body form-encoded. Câmpurile depind de grant_type; credențialele clientului depind de metoda lui de autentificare.

grant_type*string
Valoare din"authorization_code""refresh_token""urn:ietf:params:oauth:grant-type:device_code"
code?string

authorization_code — codul primit la redirect.

redirect_uri?string

authorization_code — trebuie să fie egal cu valoarea folosită la /auth.

Formaturi
code_verifier?string

authorization_code — verificatorul PKCE (43–128 caractere) al cărui hash S256 a fost trimis ca code_challenge.

refresh_token?string

Grant-ul refresh_token.

device_code?string

Grant-ul device_code — de la /device/auth.

scope?string

Restrângere opțională a scope-urilor la refresh.

resource?string

Indicator de resursă RFC 8707.

Formaturi
client_id?string

Clienți publici (none) și client_secret_post.

client_secret?string

Doar client_secret_post.

client_assertion_type?string

Doar private_key_jwt.

client_assertion?string

private_key_jwt — JWT semnat cu o cheie din jwks / jwks_uri înregistrate ale clientului.

Corpul răspunsului

Token-uri emise.

application/json
  1. response
access_token*string

Opac (1 h) sau un JWT RS256 când resource=https://ai.codai.ro/mcp.

token_type*string
expires_in*integer
scope?string

Scope-urile acordate, separate prin spațiu.

id_token?string

Prezent când s-a acordat openid. Include sub, role, sid, auth_time, acr, amr, nonce.

refresh_token?string

Doar când clientul permite refresh_token și s-a acordat offline_access. Rotit la fiecare refresh pentru clienții publici.

Exemplu de cerere
curl -X POST 'https://auth.codai.ro/token' \  -H 'Content-Type: application/x-www-form-urlencoded' \  -d 'grant_type=authorization_code'
Exemplu de răspuns
{  "access_token": "string",  "token_type": "Bearer",  "expires_in": 3600,  "scope": "string",  "id_token": "string",  "refresh_token": "string"}
POST
/token/introspection

Autorizare

clientSecretBasic
headerAutorizareBasic <token>

Autentificare client client_secret_basic. client_secret_post și private_key_jwt merg în body-ul formularului; clienții publici trimit doar client_id.

Corpul cererii

application/x-www-form-urlencoded
  1. body
token*string
token_type_hint?string
Valoare din"access_token""refresh_token"
client_id?string

Pentru client_secret_post / none.

client_secret?string

Pentru client_secret_post.

client_assertion_type?string

Pentru private_key_jwt.

client_assertion?string

Corpul răspunsului

Rezultatul introspecției (și pentru token-uri inactive).

application/json
  1. response
active*boolean
scope?string
client_id?string
sub?string

Id-ul utilizatorului (UUID).

token_type?string
exp?integer
iat?integer
iss?string
Formaturi
aud?string

Indicatorul de resursă pentru care a fost emis token-ul.

jti?string
Exemplu de cerere
curl -X POST 'https://auth.codai.ro/token/introspection' \  -H 'Content-Type: application/x-www-form-urlencoded' \  -d 'token=string'
Exemplu de răspuns
{  "active": true,  "scope": "string",  "client_id": "string",  "sub": "string",  "token_type": "string",  "exp": 0,  "iat": 0,  "iss": "http://example.com",  "aud": "string",  "jti": "string"}
POST
/token/revocation

Autorizare

clientSecretBasic
headerAutorizareBasic <token>

Autentificare client client_secret_basic. client_secret_post și private_key_jwt merg în body-ul formularului; clienții publici trimit doar client_id.

Corpul cererii

application/x-www-form-urlencoded
  1. body
token*string
token_type_hint?string
Valoare din"access_token""refresh_token"
client_id?string
client_secret?string
client_assertion_type?string
client_assertion?string

Corpul răspunsului

Token revocat (sau deja invalid). Body gol.

Exemplu de cerere
curl -X POST 'https://auth.codai.ro/token/revocation' \  -H 'Content-Type: application/x-www-form-urlencoded' \  -d 'token=string'
Exemplu de răspuns
Gol
GET
/me

Autorizare

bearerAuth
headerAutorizareBearer <token>

Access token OAuth emis de /token (folosit de /me și /connect/key).

Corpul răspunsului

Claim-urile subiectului token-ului.

application/json
  1. response
sub*string

Id-ul utilizatorului codai (UUID).

email?string
Formatemail
email_verified?boolean
name?string
picture?string
Formaturi
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/me'
Exemplu de răspuns
{  "sub": "string",  "email": "user@example.com",  "email_verified": true,  "name": "string",  "picture": "http://example.com"}
GET
/session/end

Parametri query

id_token_hint?string

ID token-ul emis anterior acestui client; identifică sesiunea și clientul.

post_logout_redirect_uri?string

URI-ul de redirect post-logout înregistrat al clientului.

Formaturi
state?string

Valoare opacă adăugată la redirect-ul post-logout.

client_id?string

Obligatoriu când lipsește id_token_hint și se dă un post_logout_redirect_uri.

ui_locales?string

Parametru standard OIDC; interfața codai citește în schimb ?lang=ro|en.

Corpul răspunsului

Pagina de confirmare a logout-ului (sau pagina „deconectat”).

response?stringtext/html
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/session/end'
Exemplu de răspuns
"string"
GET
/connect/key

Autorizare

bearerAuth
headerAutorizareBearer <token>

Access token OAuth emis de /token (folosit de /me și /connect/key).

Parametri header

X-Codai-Device-Name?string

Doar clienți first-party — eticheta (≤ 60 caractere) a cheii per dispozitiv; implicit Desktop.

Lungimelength <= 60

Corpul răspunsului

Cheie emisă (primul apel) sau deja emisă.

application/json
  1. response
api_key*|

Cheia în clar, întoarsă o singură dată per grant (null după). O stochezi sigilată.

api_key_id*string

Id-ul stabil al cheii emise (revocabilă din consolă).

Formatuuid
base_url*string

URL-ul de bază compatibil OpenAI cu care folosești cheia.

Formaturi
model*string
already_issued*boolean

true când textul în clar a fost deja predat la un apel anterior.

Exemplu de cerere
curl -X GET 'https://auth.codai.ro/connect/key'
Exemplu de răspuns
{  "api_key": "codai_xxxxxxxxxxxxxxxxxxxxxxxx",  "api_key_id": "b0dd218e-3bcf-4bdb-a1e3-0689d60a8afd",  "base_url": "https://ai.codai.ro/v1",  "model": "codai",  "already_issued": true}
OPTIONS
/connect/key

Parametri header

Origin?string
Formaturi

Corpul răspunsului

Preflight acceptat.

Exemplu de cerere
curl -X OPTIONS 'https://auth.codai.ro/connect/key'
Exemplu de răspuns
Gol
GET
/health

Corpul răspunsului

Procesul este pornit.

application/json
  1. response
ok*boolean
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/health'
Exemplu de răspuns200
{  "ok": true}
GET
/health/ready

Corpul răspunsului

Baza de date este accesibilă.

application/json
  1. response
ok*boolean
checks*
Exemplu de cerere
curl -X GET 'https://auth.codai.ro/health/ready'
Exemplu de răspuns
{  "ok": true,  "checks": {    "db": {      "ok": true,      "error": "string"    }  }}

Ultima actualizare: