Skip to navigation

V1 to V2

V2 is the Legacy version. If you are changing your app anyway, go straight to V3 with the V1 to V3 guide. It is the same amount of work and you will not have to move again. Use this page only if you must stay on the V2 contract for now, for example because a V2 SDK is already built into your tools.

V1 and V2 use the same application details, the same routes and the same request fields. Your users, licenses, plans and variables are shared, so nothing in the dashboard changes. What V2 adds is protection for the conversation between your app and AuthlyX: every request carries a one-time ID, and every reply is signed.

What changed from V1

V1V2
Base address/api/v1//api/v2/
Connection detailsOwner ID, app name, version, secretThe same
Request fieldssession_id, license_key, sid, and so onThe same, plus a request ID, nonce and timestamp
RepliesPlain JSONJSON plus an Ed25519 signature in the headers
Repeated requestsAcceptedA request ID and nonce can only be used once
SessionsV1 sessionsV2 sessions. A V1 session_id is refused by V2, so call init again
extendsid optionalsid (or hwid) required
Blacklist checkNot availablePOST /api/v2/blacklist/check

Everything else, including the reply fields, error codes and update information, is the same.

If you use an SDK

The V2 SDKs do all of the above for you. Replace your V1 file or package with the V2 SDK for your language, keep the same four values, and rebuild:

LanguageV2 SDKCreate the client
C#NuGet AuthlyX 2.4new Auth(ownerId, appName, version, secret)
C++AuthlyX.h 2.4AuthlyX AuthlyXApp(ownerId, appName, version, secret);
Pythonauthlyx-api 2.4AuthlyX(ownerId, appName, version, secret)
JavaScriptAuthlyX.js 2.4new AuthlyX(ownerId, appName, version, secret)
TypeScriptnpm authlyx 2.4new AuthlyX(ownerId, appName, version, secret)
JavaAuthlyX.java 2.4new AuthlyX(ownerId, appName, version, secret)
Goauthlyx.go 2.4NewAuthlyX(ownerID, appName, version, secret, true, "")
Rustauthlyx.rs 2.4AuthlyX::new(owner_id, app_name, version, secret, true, None, true)

The V2 SDKs come with these calls. Names are PascalCase in C#, C++, Python, JavaScript, TypeScript, Java and Go, and snake_case in Rust:

CallWhat it doesV1 route
Init()Starts a sessioninit
Login(username, password)Username and password sign-inlogin
Login(licenseKey)License sign-inlicenses
Login(deviceId, null, "motherboard")Device sign-in by serial numberdevice-auth
Register(username, password, licenseKey, email)Creates an accountregister
ChangePassword(old, new)Changes the passwordchange-password
ExtendTime(username, licenseKey)Adds a license’s time to an accountextend
GetVariable(key), SetVariable(key, value)Cloud variablesvariables, variables/set
Log(message)Writes to your app’s logslogs
ValidateSession()Checks the session is still allowedvalidate-session

In Go, pass empty strings for the values you do not use, as in Login(licenseKey, "", ""). In Rust, pass None, as in login(&key, None, None).

After each call, read app.response.success and app.response.message, and after sign-in read app.userData. The V2 docs cover the V2 contract in full.

If you call the API yourself

1. Change the address

Replace /api/v1/ with /api/v2/ in every request. Then call init again: V1 sessions do not work on V2.

2. Send a request ID, nonce and timestamp

Every V2 request needs three extra values. Send them as headers or as fields in the JSON body. If you send both, they must match.

HeaderBody fieldRule
X-Request-Idrequest_idUp to 128 letters, numbers, ., _, : or -
X-Auth-Noncenonce16 to 256 letters, numbers, _ or -. Use random bytes as hex
X-Auth-TimestamptimestampThe current time in milliseconds. Must be within 5 minutes of the server’s clock

A request ID and nonce pair can be used once. Sending the same pair again within 10 minutes is refused with AUTH_REPLAY_DETECTED. A clock that is more than 5 minutes off is refused with AUTH_INVALID_TIMESTAMP.

POST /api/v2/licenses
X-Request-Id: 6f1c0a2e-0b8e-4c3e-9a51-3f2d7e1b9c40
X-Auth-Nonce: 9b3f6c1d2e4a5b7c8d9e0f1a2b3c4d5e
X-Auth-Timestamp: 1798700000000
{
"session_id": "dc1ce...a3a75",
"license_key": "MAYA-4R8P-2N6K-9Q3W",
"sid": "S-1-5-21-..."
}

3. Check the reply signature

Every V2 reply, including errors, carries these headers:

HeaderContains
x-v2-request-idYour request ID
x-v2-nonceYour nonce
x-v2-timestampYour timestamp
x-v2-signatureThe Ed25519 signature, in base64
x-v2-signature-tsWhen the server signed the reply, in milliseconds
x-v2-signature-kidWhich signing key was used

To check a reply:

  1. Confirm x-v2-request-id and x-v2-nonce match what you sent. If they do not, discard the reply.
  2. Rebuild the signed text: the value of x-v2-signature-ts, a newline, the request ID, a newline, the nonce, a newline, then the reply body as canonical JSON. Canonical JSON means object keys sorted alphabetically at every level and no spaces between values.
  3. Verify the base64 signature over that text with the AuthlyX V2 public key for the key ID in x-v2-signature-kid. Use the public key that ships in the V2 SDKs.
  4. Only then trust success and the rest of the body.

If the signature is missing or wrong, treat the reply as if the request failed. Do not unlock anything.

4. Send sid on extend

POST /api/v2/extend needs sid or hwid, the same identifier you send at sign-in.

Test it

  1. Start a V2 session and sign in with a test license, a test user and, if you use it, a test device.
  2. Send the same request twice and check that the second one is refused.
  3. Change one character of a reply body in a debugger and check that your app rejects it.
  4. Ban, pause and expire the test account in the dashboard and check that validate-session reports it.
  5. Add the new version to Allowed Versions before you ship, and keep the V1 version allowed until users have updated.