For Developers

Getting Started

This guide will get you to recording your first audit log Event and displaying it inside your product.

You do not need an LMS or SIS integration to use Audit Logs. A Schema is recommended later (created in the dashboard), but it is not required for this walkthrough.

1. Create an Application and Copy Your Keys

  1. Create or go to your team in the Edlink Dashboard.
  2. Create an application and copy its secret key and publishable key (pk_...) for later.

You will send the secret key as a bearer token when recording Events and creating sessions. You will use the publishable key in the browser to embed the widget.

Keep the secret key on your server. Never put it in client-side code, mobile apps, or repositories. The publishable key (pk_...) is safe to use in public environments.

2. Record Your First Event

Pick a scope that matches how you group users in your own system. Something like a tenant_id, account_id, or team_id. You will reuse this same string when you list Events for this user.

Send a login Event from your backend. actor, action, targets, and scope are required:

import { Edlink } from '@edlink/typescript';

const edlink = new Edlink({
    version: 2,
    client_id: '3a95a779-0ed1-499b-a352-9ea30d0bd5ea',
    client_secret: '...'
});

const scope = 'acme-school-7f3a';

const result = await edlink.meta.audit_events.create({
    action: 'user.login.success',
    severity: 'medium',
    actor: {
        identifiers: [{ value: 'user_0001', issuer: 'acme' }],
        type: 'person'
    },
    targets: [{ identifiers: [{ value: 'user_0001', issuer: 'acme', name: 'Ada Lovelace' }], type: 'person' }],
    scope,
    context: {
        source: 'server',
        http_method: 'POST',
        http_status: 200,
        path: '/login',
        ip: '1.1.1.1'
    },
    data: {
        application_name: 'Acme Ace Grader',
        login_method: 'password'
    }
});

console.log(result);

Call this code from the same place in your product that already handles the action (for example, after a successful login). Repeat the pattern for other actions you care about: logouts, permission changes, resource access, and so on.

Identify users on actor with your own issuer (for example acme). If you also have an Edlink person UUID, add a second identifier with issuer: "edlink" and Edlink can enrich the Event when it is read back.

3. Confirm the Event Was Recorded

Fetch the event just to make sure it has been recorded. Results are reverse-chronological:

const event = await edlink.meta.audit_events.fetch(result.id);

console.log(event);

You should see the login Event you just sent.

4. Show Events in Your Product

Using your application_secret create a short-lived session for the same scope, then send the response to your frontend.

On your server:

const session = await edlink.meta.audit_sessions.create(scope);
// Return session.id and session.key to your frontend.

In the browser we will mount the Audit Logs widget with the Edlink Widgets SDK:

<script src="https://ed.link/widgets/edlink@1.0.0.js"></script>
<div id="edlink-widget-root" style="height: 100%"></div>
const edlink = new Edlink({
    client_id: '00000000-0000-0000-0000-000000000000',
    publishable_key: 'pk_...'
});

const widget = edlink.createWidget({
    root: document.getElementById('edlink-widget-root')
});

// Here you pass the session ID and Key that you got from your backend.

widget.activatePlugin({
    name: 'audit_logs_browse',
    options: {
        session_id: session.id,
        session_key: session.key
    }
});

client_id is your application ID from the dashboard. Sessions default to one hour. Anyone who receives session_id + session_key can read every Event under that scope for your application, so only provide these values to users you know are authorized to see these events.

Next Steps

Add starter Schemas or your own in the dashboard. This will give you a schema to validate against and allow you to tag actions with a type: create, read, update, delete, or other.