---
title: "Generate proxy lines"
method: POST
path: "/api/v1/plans/{id}/generate"
tags: ["Plans & line generation"]
---

# Generate proxy lines

`POST /api/v1/plans/{id}/generate`

## Request

- Base URL: `https://hproxy.com`
- URL: `https://hproxy.com/api/v1/plans/{id}/generate`
- Auth: API key in header `X-API-Key`

Turn a **gateway** plan you own into ready-to-use proxy lines, fully programmatic, using the same hardened generator the dashboard uses. Every product whose `delivery` is `lines` on [products](/docs/proxy-api/products) generates (residential, mobile, ISP rotating, IPv4 and IPv6 per GB); the product's `generate` block, and each plan's, says which targeting fields its network takes. Lines come back as `host:port:username:password` with the targeting baked into the username, so any client that accepts a proxy username and password uses them without extra settings. Chrome and other Chromium browsers never send a SOCKS5 username and password, so for them generate with `protocol` set to `http`, the default. Every field is optional; an empty body returns one rotating line with the plan's defaults. Generating lines is free and repeatable: traffic is only consumed when the lines are used. All generated lines draw from the SAME plan balance. Dedicated per-IP products don't generate; fetch them from [GET /proxies](/docs/proxy-api/proxies) instead.

## Path parameters

- `id` string, required

## Request body

- object
  - `protocol` string: "http" (default) or "socks5".
  - `count` integer: Lines to return, 1 to 5000, and at most the plan's own `generate.maxCount` (5,000 on Residential Premium, 1,000 on Residential Lite); a count past it answers 400 `invalid_count` naming the ceiling. Default 1. Sticky and rotating batches share this limit: on Residential Premium sticky lines take the sticky ports in turn and every line holds its own session, so the number of ports never limits a batch. Each plan's `generate.sticky` block carries the sticky port range (`port`, `ports`).
  - `country` string: Country targeting, e.g. "US" (letters only, 2 to 40 chars). This is where a residential order gets its country: the order carries none, so one plan serves every country and each call can target a different one.
  - `state` string: State / region targeting, where the pool supports it.
  - `city` string: City targeting, where the pool supports it.
  - `isp` string: ISP targeting by name. Residential Plus plans only (400 on other products).
  - `asn` integer: ISP targeting by AS number, e.g. 7018 for AT&T or 7922 for Comcast, together with `country`. Residential Premium plans only; the list per country is `GET /v1/products/residential-premium/geo/asns?country=US`. 400 on other products.
  - `os` string: "windows", "android", "ios" or "mac": the device the exit IP belongs to. Residential Premium only.
  - `strict` boolean: Default true: a target with no IP free fails the request. false: the gateway hands out another IP from the same country instead. Residential Premium only.
  - `excludeAsn` integer: Up to 20 AS numbers to avoid. Not together with `excludeCountries`. Residential Premium only.
  - `excludeCountries` unknown[]: Up to 20 two-letter country codes to avoid; only without `country`. Residential Premium only. One exclusion kind per call: countries, states, cities or networks, never two.
    - unknown
  - `excludeStates` unknown[]: Up to 20 state / region names to avoid inside `country` (e.g. ["California", "Texas"]); not together with a `state` target. Residential Premium only.
    - unknown
  - `excludeCities` unknown[]: Up to 20 city names to avoid inside `country` (e.g. ["New York", "Houston"]); not together with a `city` target. Residential Premium only.
    - unknown
  - `udp` boolean: `true` lets a `socks5` line open UDP relays (SOCKS5 UDP ASSOCIATE). Refused on `http`. Residential Premium only.
  - `stickyMinutes` integer: Turns sticky on. Omit for rotating IPs. On Residential Premium the number is the session length in minutes, 3 to 1440 (24 hours), and each sticky line holds its own session with no limit on how many; on Plus it is the session length up to 24 hours. On Residential Lite the pool takes no duration, so any value above 0 simply turns sticky on and the session lasts as long as you keep reusing the line. Each plan's `generate` block reports its own `minStickyMinutes` / `maxStickyMinutes`.

## Response `200`

Success

- object

## Other responses

- `400`: Invalid input. The body names the field and the accepted set.
- `401`: Missing or invalid API key.
- `429`: Rate limited. Retry after the delay in the response.

---

[API](https://skmtc.dev/hproxy/apis/hproxy-api.md) · [All operations](https://skmtc.dev/hproxy/apis/hproxy-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hproxy/apis/hproxy-api/revisions/9f6898fe76e2?raw)
