C guide
This page walks through the whole C SDK in the order you would use it. Each step starts with the shortest code that works.
Download the C SDK if you have not done so yet.
Requirements
Ed25519, SHA-256, SHA-512, PBKDF2 and JSON are built in, so there is no OpenSSL dependency. On Windows, HTTPS uses WinHTTP and the Windows certificate store.
On Linux and macOS, pass your own system_id and store when you create the client, as shown in Options.
Add the SDK to your project
The whole SDK is the single file authlyx.h. Copy it into your project. In exactly one .c file, define AUTHLYX_IMPLEMENTATION before including it:
Every other file that uses the SDK includes authlyx.h without the define. With MSVC the Windows libraries are linked automatically. With other compilers, link winhttp bcrypt crypt32 advapi32 user32 shell32 on Windows, or curl pthread m on Linux and macOS.
The example on GitHub also has a CMake project. Add its folder and link the authlyx target:
To use libcurl on Windows instead of WinHTTP, define AUTHLYX_USE_CURL in the file with AUTHLYX_IMPLEMENTATION, or turn on the AUTHLYX_USE_CURL CMake option.
Create the client
The first value is your app’s AppKey. Find it in the dashboard under your application’s credentials. The second is the version of the program you are building. AuthlyX compares it with the versions you allow in the dashboard, so raise it each time you ship a new build. See Allowed Versions.
Create one client for the whole program and free it with authlyx_destroy when the program exits.
How calls work
Every call takes the client, its own values and a pointer to an authlyx_result. It waits for the reply, fills the result and returns 1 on success or 0 on failure:
Always free a result with authlyx_result_free before you reuse it. Pass NULL instead of a result when you only need the return value.
A client can be used from several threads. Calls are processed one at a time.
Start the SDK
authlyx_init connects to AuthlyX, checks that this version is allowed and loads your app’s settings. It must succeed before anything else.
Sign in
These are three ways to sign in. Use the one that matches the access type you created in the dashboard. Passing NULL as the password to authlyx_login signs in with a license key. Device login signs in the current Windows user with no form, and only works for devices you approved first; see Device login.
Create an account, change the password, add time
authlyx_register creates the account with a license and signs it in. authlyx_redeem_license adds a license’s time to the signed-in account.
Read the account
authlyx_user_string returns a copy of one field as text, or NULL when it is missing. Free it with authlyx_free. The fields are listed in User Data.
authlyx_user_data returns a copy of every field as a value, which you free with authlyx_value_free:
Reading values
Data from AuthlyX, such as result.data and authlyx_user_data, is an authlyx_value. These functions read it:
Every reader accepts NULL, so you can chain them without checking each step. Values read from a result stay valid until you free that result.
Features and metadata
Features come from the plan and the account. Some are on/off, some carry a value such as "high" or 90. Metadata is extra information attached to accounts. See Features and metadata.
authlyx_get_features lists every feature and authlyx_get_feature returns one. For metadata, use authlyx_get_all_metadata, authlyx_get_metadata and authlyx_check_metadata.
Save metadata
authlyx_set_metadata saves text. authlyx_set_metadata_json saves a number, a list or an object written as JSON.
Cloud variables
For authlyx_get_variable, data is the value itself. See Cloud variables.
Scripts
The third value is the revision. -1 asks for the current one. The SDK checks the script’s signature before returning it. It does not run the script. See Scripts.
Logs and webhooks
Webhook data is passed as JSON text. See Logs and Webhooks.
Staying signed in
After sign-in the SDK checks in with AuthlyX on a background thread (a heartbeat) at the interval the server sets, and refreshes features and metadata each time. If you ban, pause or expire the account, the next heartbeat ends the session.
To be told when the session ends, set the callbacks before you create the client:
on_connection receives online, disconnected, untrusted or disposed. callback_context is passed to both callbacks. Callbacks can run on the background thread, so keep them short.
To check right away, call authlyx_check_session, for example when your app wakes from sleep. To run the heartbeat yourself, set options.heartbeat = AUTHLYX_HEARTBEAT_MANUAL and call authlyx_check_session from your own timer. More in Sessions and heartbeats.
Offline access
Later, without internet, authlyx_init succeeds with OFFLINE_MODE, and the user signs in with the same license key or username and password. The SDK checks them against the saved permit and the sign-in succeeds with the code OFFLINE_ACCESS. authlyx_has_offline_access tells you whether this PC has a valid saved permit. Signing out deletes it. See Offline access.
Updates
When this version is not allowed, authlyx_init fails with UPDATE_REQUIRED or VERSION_MISMATCH and the SDK shows a message box with the new version, release notes and a button to open your download page. To show your own window, set options.update_prompt = 0 and read the details:
See Automatic updates.
Sign out and shut down
authlyx_logout ends the session, clears the account and deletes saved offline access on this PC. authlyx_destroy stops the background thread and frees the client; call it when your program exits.
GUI apps
Every call waits for the reply. In a GUI, make calls from a worker thread, not the UI thread, or the window stops responding while AuthlyX answers. Pass the result back to the UI thread with your framework’s message mechanism, such as PostMessage in a Win32 app.
Results and errors
network means the SDK could not reach AuthlyX or confirm the answer; do not treat it as a ban. security means a reply failed its signature checks. client means a value you passed was not valid. All codes are listed in Errors.
Options
Start from authlyx_options_init and change what you need. Every option is optional on Windows.
On Linux, for example:
authlyx_file_store_create writes files readable only by the current user. authlyx_memory_store_create keeps nothing after the process ends. authlyx_protected_store_create is the Windows protected store in a folder you choose. A store you create is yours to free with authlyx_store_destroy after the client is destroyed. You can also fill an authlyx_store with your own load, save and remove functions.
A complete program
The example on GitHub is a fuller console app with a menu for every feature. Each method also has its own page with every language side by side under SDK methods.

