# Create Proxy Session — Oxylabs

> Establish a proxy session using the Residential Proxy endpoint. See the documentation

- Key: `oxylabs-create-proxy-session`
- Type: Action (Write)
- Version: 0.0.4
- App: Oxylabs (`oxylabs`) — https://pipedream.com/apps/oxylabs.md
- This page (HTML): https://pipedream.com/apps/oxylabs/actions/create-proxy-session
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/oxylabs/actions/create-proxy-session/create-proxy-session.mjs

## Description

Establish a proxy session using the Residential Proxy endpoint. [See the documentation](https://developers.oxylabs.io/proxies/residential-proxies/session-control#establishing-session)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `username` | `string` | Yes | The username for the proxy user |
| `password` | `string` | Yes | The password for the proxy user |
| `sessid` | `string` | Yes | Session ID to keep the same IP with upcoming queries. The session expires in 10 minutes. After that, a new IP address is assigned to that session ID. Random string, 0-9, and A-Z characters are supported. |
| `cc` | `string` | No | Case insensitive country code in 2-letter 3166-1 alpha-2 format |
| `city` | `string` | No | Case insensitive city name in English. This parameter must be accompanied by cc for better accuracy. |
| `st` | `string` | No | Case insensitive US state name with us_ in the beginning, for example, us_california, us_illinois |
| `sstime` | `string` | No | Session time in minutes. The session time parameter keeps the same IP for a certain period. The maximum session time is 30 minutes. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "oxylabs",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "oxylabs-create-proxy-session",
  arguments: {
    username: "Username",
    password: "Password",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "oxylabs-create-proxy-session",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    oxylabs: { authProvisionId: "apn_xxxxxxx" },
    username: "Username",
    password: "Password",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "oxylabs-create-proxy-session",
    "configured_props": {
      "oxylabs": { "authProvisionId": "apn_xxxxxxx" },
      "username": "Username",
      "password": "Password"
    }
  }'
```

---

- App: https://pipedream.com/apps/oxylabs.md · All apps: https://pipedream.com/apps
