Skip to main content

Manage a connection

You can manage various aspects of your connection by updating connection attributes. This allows you to do things like set routing rules, change IP address, or geo target IPs.

For custom workflows, you can use the flexible Aluvia API directly. The Aluvia SDK offers language-specific API wrappers.

Updating connection attributes with Aluvia Client

While your agent is running, you can update routing rules, rotate IPs, or change geo targeting—no restart needed:

await client.updateRules(['blocked-site.com']);    // Add hostname to proxy rules
await client.updateSessionId('session1'); // Rotate to a new IP
await client.updateTargetGeo('us_ca'); // Target California IPs

Updating session ID

Use session IDs for sticky sessions and IP rotation.

await client.updateSessionId('session1');       // Rotate to a new IP

Example: Updating session ID (various tools)

import { chromium } from 'playwright';
import { AluviaClient } from '@aluvia/sdk';

const client = new AluviaClient({
apiKey: process.env.ALUVIA_API_KEY!,
connectionId: process.env.ALUVIA_CONNECTION_ID!, // required to update session_id
});

const connection = await client.start();

const browser = await chromium.launch({
proxy: connection.asPlaywright(),
});

try {
const context = await browser.newContext();
const page = await context.newPage();

// "Session 1"
await client.updateSessionId('session1');
await page.goto('https://ipconfig.io/json');

// "Session 2"
await client.updateSessionId('session2');
await page.goto('https://ipconfig.io/json');
} finally {
await browser.close();
await connection.close();
}

Updating routing rules

Routing rules allow you to specify which hostnames should be routed through Aluvia. Rules can be updated during runtime, allowing agents to work around website blocks on the fly.

await client.updateRules(['blocked-site.com']);    // Add hostname to proxy rules

Example: Updating routing rules (various tools)

import { chromium } from 'playwright';
import { AluviaClient } from '@aluvia/sdk';

const client = new AluviaClient({
apiKey: process.env.ALUVIA_API_KEY!,
connectionId: process.env.ALUVIA_CONNECTION_ID!, // required to update rules
});
const connection = await client.start();

const browser = await chromium.launch({
proxy: connection.asPlaywright(),
});

try {
const context = await browser.newContext();
const page = await context.newPage();

// Rules 1: proxy ipconfig.io only
await client.updateRules(['ipconfig.io']);
await page.goto('https://ipconfig.io/json');

// Rules 2: add a new rule (also proxy example.com)
await client.updateRules(['ipconfig.io', 'example.com']);
await page.goto('https://example.com');
} finally {
await browser.close();
await connection.close();
}

Geo Targeting

Geo targeting IP addresses allows you to request IP addresses from a specific state.

await client.updateTargetGeo('us_ca');             // Target California IPs

Example: Updating geo targeting (various tools)

import { chromium } from 'playwright';
import { AluviaClient } from '@aluvia/sdk';

const client = new AluviaClient({
apiKey: process.env.ALUVIA_API_KEY!,
connectionId: process.env.ALUVIA_CONNECTION_ID!, // required to update target_geo
});
const connection = await client.start();

const browser = await chromium.launch({
proxy: connection.asPlaywright(),
});

try {
const context = await browser.newContext();
const page = await context.newPage();

// Geo 1 (example: CA)
await client.updateTargetGeo('CA');
await page.goto('https://ipconfig.io/json');

// Geo 2 (example: NY)
await client.updateTargetGeo('NY');
await page.goto('https://ipconfig.io/json');
} finally {
await browser.close();
await connection.close();
}