<!-- llms.txt: https://workos.com/llms.txt -->
<!-- feedback.md: https://workos.com/docs/feedback.md -->

> Agents: if this page is wrong, missing a step, or its code fails, report it instead of working around it. `POST https://api.workos.com/feedback` with `Content-Type: application/json` and body `{"message":"Agent report: what you tried, what happened, client and model","pageUrl":"https://workos.com/docs/audit-logs/admin-portal"}`. Ask the user once first. No auth. No secrets. Details: https://workos.com/docs/feedback.md

# Admin Portal

## Creating Admin Portal Link

Audit Log events can be viewed in the WorkOS [Admin Portal](https://workos.com/docs/admin-portal). Links can be generated through the WorkOS API and sent to your customers for viewing events associated with their Organization.

When creating a link for an Admin Portal session, you must provide the Organization ID whose events will be displayed in the Admin Portal, and specify the intent as `audit_logs`.

:::code-group{title="Create Admin Portal Link for Audit Logs"}

```js language="js"
import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

const { link } = await workos.adminPortal.generateLink({
  organization: 'org_01EHZNVPK3SFK441A1RGBFSHRT',
  intent: 'audit_logs',
});

// Redirect to link
```

```rb language="ruby"
require "workos"

workos = WorkOS::Client.new(api_key: ENV["WORKOS_API_KEY"])

# The ID of the organization to start an Admin Portal session for
organization_id = "org_123"

link = workos.admin_portal.generate_link(
  organization: organization_id,
  intent: "audit_logs"
)

# Redirect to link
```

```py language="python"
from workos import WorkOSClient

workos_client = WorkOSClient(
    api_key="sk_example_123456789", client_id="client_123456789"
)

organization_id = (
    "org_123"  # The ID of the organization to start an Admin Portal session for
)

portal_link = workos_client.admin_portal.generate_link(
    organization=organization_id, intent="audit_logs"
)

# Redirect to portal_link.link
```

```go language="go"
package main

import (
	"context"
	workos "github.com/workos/workos-go/v10"
	"os"
)

func main() {
	apiKey := os.Getenv("WORKOS_API_KEY")

	client := workos.NewClient(apiKey)

	// The ID of the organization to start an Admin Portal session for
	organizationID := "org_123"

	link, err := client.AdminPortal().GenerateLink(context.Background(), &workos.AdminPortalGenerateLinkParams{
		Organization: organizationID,
		Intent:       workos.Ptr(workos.GenerateLinkIntentAuditLogs),
	})

	if err != nil {
		// Handle the error...
	}

	// Redirect to link.Link
	_ = link.Link
}
```

```php language="php"
<?php

$workos = new \WorkOS\WorkOS();

$portalLink = $workos
    ->adminPortal()
    ->generateLink(
        organization: "org_123",
        intent: \WorkOS\Resource\GenerateLinkIntent::AuditLogs,
    );

$url = $portalLink->link;

// Redirect to $url
```

```php language="laravel"
<?php

use WorkOS\Laravel\Facades\WorkOS;
use WorkOS\Resource\GenerateLinkIntent;

$portalLink = WorkOS::adminPortal()->generateLink(
    organization: "org_123",
    intent: GenerateLinkIntent::AuditLogs,
);

$url = $portalLink->link;

// Redirect to $url
```

```java language="java"
import com.workos.WorkOS;
import com.workos.portal.PortalApi.GeneratePortalLinkOptions;
import com.workos.portal.models.Intent;
import com.workos.portal.models.Link;

Map<String, String> env = System.getenv();
WorkOS workos = new WorkOS(env.get("WORKOS_API_KEY"));

// The ID of the organization to start an Admin Portal session for
String organizationId = "org_123"

    Link response = workos.portal.generateLink(GeneratePortalLinkOptions.builder()
                                                   .organization()
                                                   .intent(Intent.AuditLogs)
                                                   .build());

String link = response.link

              // Redirect to response.link
```

```cs language="dotnet"
using System;
using WorkOS;

var portalService = new PortalService();

// The ID of the organization to start an Admin Portal session for
string organizationId = "org_123";

var options = new GenerateLinkOptions {
    Intent = Intent.AuditLogs,
    Organization = organizationId,
};

var link = await portalService.GenerateLink(options);

// Redirect to the portal link
```

:::

Navigating to the provided link will result in the following view. Users will be able to view and export Audit Log events just as can be done through the WorkOS Dashboard.

![A screenshot showing Audit Log events in the WorkOS Admin Portal.](https://images.workoscdn.com/images/e08a07dd-4539-4c5a-9802-63d7c774b2c9.png?auto=format\&fit=clip\&q=50)
