Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Client options

HTTP

No client to configure — just set your base URL and auth token in each request:

export BASE_URL=http://localhost:3000
export AUTH_TOKEN=your-secret-token

# All requests:
curl -s $BASE_URL/endpoint \
  -H "Authorization: Bearer $AUTH_TOKEN" \
  -H "Content-Type: application/json"

See Environment Variables for daemon configuration.

JavaScript

Pass options to PortalClient:

OptionRequiredDescription
baseUrlYesHTTP base URL (e.g. http://localhost:3000)
authTokenYesBearer token matching PORTAL__AUTH__AUTH_TOKEN
autoPollingIntervalMsNoEnable auto-polling; interval in ms (e.g. 2000)
import { PortalClient } from 'portal-sdk';

const client = new PortalClient({
  baseUrl: 'http://localhost:3000',
  authToken: 'your-auth-token',
  autoPollingIntervalMs: 2000  // optional: poll every 2s automatically
});

// Stop auto-polling when done
client.destroy();
Java

Use PortalClientConfig builder:

import cc.getportal.PortalClient;
import cc.getportal.PortalClientConfig;

// Manual polling
PortalClient client = new PortalClient(
    PortalClientConfig.create("http://localhost:3000", "your-auth-token")
);

// Auto-polling every 2 seconds
PortalClient client = new PortalClient(
    PortalClientConfig.create("http://localhost:3000", "your-auth-token")
                      .autoPolling(2000)
);

// Webhook mode
PortalClient client = new PortalClient(
    PortalClientConfig.create("http://localhost:3000", "your-auth-token")
                      .webhookSecret("your-webhook-secret")
);

Next: Error Handling